Module: Ork::Embeddable
- Defined in:
- lib/ork/model/embedded.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Check for equality by doing the following assertions:.
- #__parent ⇒ Object
- #__parent=(object) ⇒ Object
- #embeddable? ⇒ Boolean
-
#inspect ⇒ Object
Pretty print for the model.
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Check for equality by doing the following assertions:
-
That the passed model is of the same type.
-
That they have the same attributes.
How it was developed, 2 implies 1.
30 31 32 33 34 |
# File 'lib/ork/model/embedded.rb', line 30 def ==(other) other.kind_of?(model) && __persist_attributes == other.__persist_attributes && other.attributes[model.__parent_key] == @attributes[model.__parent_key] end |
#__parent ⇒ Object
15 16 17 |
# File 'lib/ork/model/embedded.rb', line 15 def __parent @attributes[model.__parent_key] or raise Ork::ParentMissing end |
#__parent=(object) ⇒ Object
19 20 21 |
# File 'lib/ork/model/embedded.rb', line 19 def __parent=(object) @attributes[model.__parent_key] = object end |
#embeddable? ⇒ Boolean
11 12 13 |
# File 'lib/ork/model/embedded.rb', line 11 def true end |
#inspect ⇒ Object
Pretty print for the model
Example:
User.new(name: 'John').inspect
# => #<User {:name=>"John"}>
44 45 46 |
# File 'lib/ork/model/embedded.rb', line 44 def inspect "#<#{model} #{attributes.inspect}>" end |