Sha256: 27b19b25fbd978c509ae3a29126c6af6d90378bfd8ffd486212ce877fbe9b377
Contents?: true
Size: 1.26 KB
Versions: 20
Compression:
Stored size: 1.26 KB
Contents
require 'locomotive/steam/adapters/memory' require 'morphine' module Locomotive::Steam module Models # Note: represents an embedded collection class EmbeddedAssociation include Morphine register :adapter do Locomotive::Steam::MemoryAdapter.new(nil) end # 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. def initialize(repository_klass, collection, scope, options = {}) adapter.collection = collection || [] @repository = repository_klass.new(adapter) @repository.scope = scope @options = options end # In order to keep track of the entity which owns # the association. def __attach__(entity) name = @options[:mapper_name].to_s.singularize.to_sym @repository.send(:"#{name}=", entity) end def __serialize__(entity) # TODO: not implemented yet end def method_missing(name, *args, &block) @repository.send(name, *args, &block) end def respond_to_missing?(name, include_private = false) @repository.respond_to?(name) || super end end end end
Version data entries
20 entries across 20 versions & 1 rubygems