Module: Locomotive::Steam::Models::Entity
- Includes:
- Concerns::ToJson, Concerns::Validation
- Included in:
- ContentEntry, ContentType, ContentTypeField, ContentTypeField::SelectOption, EditableElement, Page, Section, Site, Snippet, ThemeAsset, Translation
- Defined in:
- lib/locomotive/steam/models/entity.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#as_json, #to_hash, #to_json
#errors, #valid?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/locomotive/steam/models/entity.rb', line 14
def method_missing(name, *args, &block)
_name = name.to_s
if attributes.include?(_name)
self[_name]
elsif _name.end_with?('=') && attributes.include?(_name.chop)
self[_name.chop] = args.first
else
super
end
end
|
Instance Attribute Details
#associations ⇒ Object
Returns the value of attribute associations.
8
9
10
|
# File 'lib/locomotive/steam/models/entity.rb', line 8
def associations
@associations
end
|
#attributes ⇒ Object
Returns the value of attribute attributes.
8
9
10
|
# File 'lib/locomotive/steam/models/entity.rb', line 8
def attributes
@attributes
end
|
#base_url ⇒ Object
Returns the value of attribute base_url.
8
9
10
|
# File 'lib/locomotive/steam/models/entity.rb', line 8
def base_url
@base_url
end
|
#localized_attributes ⇒ Object
Returns the value of attribute localized_attributes.
8
9
10
|
# File 'lib/locomotive/steam/models/entity.rb', line 8
def localized_attributes
@localized_attributes
end
|
Instance Method Details
#[](name) ⇒ Object
37
38
39
|
# File 'lib/locomotive/steam/models/entity.rb', line 37
def [](name)
attributes[name]
end
|
#[]=(name, value) ⇒ Object
33
34
35
|
# File 'lib/locomotive/steam/models/entity.rb', line 33
def []=(name, value)
attributes[name] = value
end
|
#_id ⇒ Object
29
30
31
|
# File 'lib/locomotive/steam/models/entity.rb', line 29
def _id
self['_id']
end
|
#change(new_attributes) ⇒ Object
41
42
43
44
|
# File 'lib/locomotive/steam/models/entity.rb', line 41
def change(new_attributes)
attributes.merge!((new_attributes || {}).with_indifferent_access)
self
end
|
#initialize(attributes) ⇒ Object
10
11
12
|
# File 'lib/locomotive/steam/models/entity.rb', line 10
def initialize(attributes)
@attributes = attributes.with_indifferent_access
end
|
#respond_to?(name, include_private = false) ⇒ Boolean
25
26
27
|
# File 'lib/locomotive/steam/models/entity.rb', line 25
def respond_to?(name, include_private = false)
attributes.include?(name.to_s) || super
end
|
#serialize ⇒ Object
46
47
48
|
# File 'lib/locomotive/steam/models/entity.rb', line 46
def serialize
attributes.dup
end
|