Module: Ork::Embeddable

Defined in:
lib/ork/model/embedded.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



6
7
8
9
# File 'lib/ork/model/embedded.rb', line 6

def self.included(klass)
  klass.send(:include, Ork::Model)
  klass.extend(Ork::Model::Embedded::ClassMethods)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Check for equality by doing the following assertions:

  1. That the passed model is of the same type.

  2. 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

#__parentObject



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

Returns:

  • (Boolean)


11
12
13
# File 'lib/ork/model/embedded.rb', line 11

def embeddable?
  true
end

#inspectObject

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