Sha256: e7960a280684691dbe0a96dd4a1418f808e783eb8899b48d3363dd48155f3d3b
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
module Locomotive::Steam module Models class ReferencedAssociation attr_reader :repository def initialize(repository_klass, scope, adapter, options = {}, &block) # build a new instance of the target repository @repository = repository_klass.new(adapter) # Note: if we change the locale of the parent repository, that won't # reflect in that repository @repository.scope = scope.dup # the block will executed when a method of the target will be called @block = block_given? ? block : nil @options = options end def __attach__(entity) @entity = entity end def __load__ # needs implementation end def __call_block_once__ # setup the repository if custom configuration from the # repository for instance. if @block @block.call(@repository, @options) @block = nil # trick to call it only once end end def method_missing(name, *args, &block) __call_block_once__ __load__.try(:send, name, *args, &block) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems