Module: OrientDB::AR::Attributes
Instance Method Summary collapse
- #[](attr) ⇒ Object
- #[]=(attr, value) ⇒ Object
- #attribute_names ⇒ Object
- #attributes ⇒ Object
- #changed ⇒ Object
- #changed? ⇒ Boolean
- #changed_attributes ⇒ Object
- #changes ⇒ Object
- #previous_changes ⇒ Object
Instance Method Details
#[](attr) ⇒ Object
15 16 17 18 |
# File 'lib/model/attributes.rb', line 15 def [](attr) res = @odocument[attr] res.respond_to?(:jruby_value) ? res.jruby_value : res end |
#[]=(attr, value) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/model/attributes.rb', line 20 def []=(attr, value) old_value = self[attr] return old_value if value == old_value attribute_will_change!(attr) @odocument[attr] = value end |
#attribute_names ⇒ Object
6 7 8 9 |
# File 'lib/model/attributes.rb', line 6 def attribute_names schema_names = self.class.fields.keys.map { |x| x.to_s } (schema_names + @odocument.field_names.map).uniq end |
#attributes ⇒ Object
11 12 13 |
# File 'lib/model/attributes.rb', line 11 def attributes attribute_names.inject({}) { |h, attr| h[attr.to_s] = self[attr]; h } end |
#changed ⇒ Object
31 32 33 |
# File 'lib/model/attributes.rb', line 31 def changed changed_attributes.keys end |
#changed? ⇒ Boolean
27 28 29 |
# File 'lib/model/attributes.rb', line 27 def changed? !changed_attributes.empty? end |
#changed_attributes ⇒ Object
43 44 45 |
# File 'lib/model/attributes.rb', line 43 def changed_attributes @changed_attributes ||= HashWithIndifferentAccess.new end |
#changes ⇒ Object
35 36 37 |
# File 'lib/model/attributes.rb', line 35 def changes changed.inject(HashWithIndifferentAccess.new) { |h, attr| h[attr] = attribute_change(attr); h } end |
#previous_changes ⇒ Object
39 40 41 |
# File 'lib/model/attributes.rb', line 39 def previous_changes @previously_changed end |