Class: ForestLiana::Model::Collection
- Inherits:
-
Object
- Object
- ForestLiana::Model::Collection
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Serialization, ActiveModel::Validations
- Defined in:
- app/models/forest_liana/model/collection.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#icon ⇒ Object
Returns the value of attribute icon.
-
#integration ⇒ Object
Returns the value of attribute integration.
-
#is_read_only ⇒ Object
Returns the value of attribute is_read_only.
-
#is_searchable ⇒ Object
Returns the value of attribute is_searchable.
-
#is_virtual ⇒ Object
Returns the value of attribute is_virtual.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_old ⇒ Object
Returns the value of attribute name_old.
-
#only_for_relationships ⇒ Object
Returns the value of attribute only_for_relationships.
-
#pagination_type ⇒ Object
Returns the value of attribute pagination_type.
-
#search_fields ⇒ Object
Returns the value of attribute search_fields.
-
#segments ⇒ Object
Returns the value of attribute segments.
Instance Method Summary collapse
- #fields_smart_belongs_to ⇒ Object
- #id ⇒ Object
- #init_properties_with_default ⇒ Object
-
#initialize(attributes = {}) ⇒ Collection
constructor
A new instance of Collection.
- #persisted? ⇒ Boolean
- #string_smart_fields_names ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Collection
Returns a new instance of Collection.
13 14 15 16 17 18 19 |
# File 'app/models/forest_liana/model/collection.rb', line 13 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end init_properties_with_default end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def actions @actions end |
#fields ⇒ Object
Returns the value of attribute fields.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def fields @fields end |
#icon ⇒ Object
Returns the value of attribute icon.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def icon @icon end |
#integration ⇒ Object
Returns the value of attribute integration.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def integration @integration end |
#is_read_only ⇒ Object
Returns the value of attribute is_read_only.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def is_read_only @is_read_only end |
#is_searchable ⇒ Object
Returns the value of attribute is_searchable.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def is_searchable @is_searchable end |
#is_virtual ⇒ Object
Returns the value of attribute is_virtual.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def is_virtual @is_virtual end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def name @name end |
#name_old ⇒ Object
Returns the value of attribute name_old.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def name_old @name_old end |
#only_for_relationships ⇒ Object
Returns the value of attribute only_for_relationships.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def only_for_relationships @only_for_relationships end |
#pagination_type ⇒ Object
Returns the value of attribute pagination_type.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def pagination_type @pagination_type end |
#search_fields ⇒ Object
Returns the value of attribute search_fields.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def search_fields @search_fields end |
#segments ⇒ Object
Returns the value of attribute segments.
7 8 9 |
# File 'app/models/forest_liana/model/collection.rb', line 7 def segments @segments end |
Instance Method Details
#fields_smart_belongs_to ⇒ Object
61 62 63 64 65 |
# File 'app/models/forest_liana/model/collection.rb', line 61 def fields_smart_belongs_to fields.select do |field| field[:'is_virtual'] && field[:type] == 'String' && !field[:reference].nil? end end |
#id ⇒ Object
57 58 59 |
# File 'app/models/forest_liana/model/collection.rb', line 57 def id name end |
#init_properties_with_default ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/forest_liana/model/collection.rb', line 21 def init_properties_with_default @name_old ||= @name @is_virtual ||= false @icon ||= nil @is_read_only ||= false @is_searchable = true if @is_searchable.nil? @only_for_relationships ||= false @pagination_type ||= "page" @search_fields ||= nil @fields ||= [] @actions ||= [] @segments ||= [] @fields = @fields.map do |field| field[:type] = "String" unless field.key?(:type) field[:default_value] = nil unless field.key?(:default_value) field[:enums] = nil unless field.key?(:enums) field[:integration] = nil unless field.key?(:integration) field[:is_filterable] = true unless field.key?(:is_filterable) field[:is_read_only] = false unless field.key?(:is_read_only) field[:is_required] = false unless field.key?(:is_required) field[:is_sortable] = true unless field.key?(:is_sortable) field[:is_virtual] = false unless field.key?(:is_virtual) field[:reference] = nil unless field.key?(:reference) field[:inverse_of] = nil unless field.key?(:inverse_of) field[:relationship] = nil unless field.key?(:relationship) field[:widget] = nil unless field.key?(:widget) field[:validations] = nil unless field.key?(:validations) field end end |
#persisted? ⇒ Boolean
53 54 55 |
# File 'app/models/forest_liana/model/collection.rb', line 53 def persisted? false end |
#string_smart_fields_names ⇒ Object
67 68 69 70 71 |
# File 'app/models/forest_liana/model/collection.rb', line 67 def string_smart_fields_names fields .select { |field| field[:'is_virtual'] && field[:type] == 'String' } .map { |field| field[:field].to_s } end |