Class: Locomotive::Steam::Models::EmbeddedAssociation
- Inherits:
-
Object
- Object
- Locomotive::Steam::Models::EmbeddedAssociation
- Includes:
- Morphine
- Defined in:
- lib/locomotive/steam/models/associations/embedded.rb
Overview
Note: represents an embedded collection
Instance Method Summary collapse
-
#__attach__(entity) ⇒ Object
In order to keep track of the entity which owns the association.
- #__serialize__(entity) ⇒ Object
-
#initialize(repository_klass, collection, scope, options = {}) ⇒ EmbeddedAssociation
constructor
use the scope from the parent repository one of the benefits is that if we change the current locale of the parent repository, that will change the local repository as well.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(repository_klass, collection, scope, options = {}) ⇒ EmbeddedAssociation
use the scope from the parent repository one of the benefits is that if we change the current locale of the parent repository, that will change the local repository as well.
20 21 22 23 24 25 26 27 |
# File 'lib/locomotive/steam/models/associations/embedded.rb', line 20 def initialize(repository_klass, collection, scope, = {}) adapter.collection = collection || [] @repository = repository_klass.new(adapter) @repository.scope = scope @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
40 41 42 |
# File 'lib/locomotive/steam/models/associations/embedded.rb', line 40 def method_missing(name, *args, &block) @repository.send(name, *args, &block) end |
Instance Method Details
#__attach__(entity) ⇒ Object
In order to keep track of the entity which owns the association.
31 32 33 34 |
# File 'lib/locomotive/steam/models/associations/embedded.rb', line 31 def __attach__(entity) name = @options[:mapper_name].to_s.singularize.to_sym @repository.send(:"#{name}=", entity) end |
#__serialize__(entity) ⇒ Object
36 37 38 |
# File 'lib/locomotive/steam/models/associations/embedded.rb', line 36 def __serialize__(entity) # TODO: not implemented yet end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
44 45 46 |
# File 'lib/locomotive/steam/models/associations/embedded.rb', line 44 def respond_to_missing?(name, include_private = false) @repository.respond_to?(name) || super end |