class Locomotive::Steam::Models::ReferencedAssociation

Attributes

repository[R]

Public Class Methods

new(repository_klass, scope, adapter, options = {}, &block) click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 8
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

Public Instance Methods

__attach__(entity) click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 26
def __attach__(entity)
  @entity = entity
end
__call_block_once__() click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 38
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
__load__() click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 30
def __load__
  # needs implementation
end
__name__() click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 22
def __name__
  @options[:association_name]
end
__serialize__(entity) click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 34
def __serialize__(entity)
  # needs implementation
end
method_missing(name, *args, &block) click to toggle source
# File lib/locomotive/steam/models/associations/referenced.rb, line 47
def method_missing(name, *args, &block)
  __call_block_once__

  __load__.try(:send, name, *args, &block)
end