Sha256: 8ebb341871bd3d49b43eda23d1d15a2133986325f1b36d178a65c4e63e6a4b65
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 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 method_missing(name, *args, &block) @repository.send(name, *args, &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_steam-1.0.0.pre.alpha | lib/locomotive/steam/models/associations/embedded.rb |