Class: AmsLazyRelationships::Loaders::Direct

Inherits:
Base
  • Object
show all
Defined in:
lib/ams_lazy_relationships/loaders/direct.rb

Overview

Lazy loads data in a “dumb” way - just executes the provided block when needed

Instance Method Summary collapse

Methods inherited from Base

#load

Constructor Details

#initialize(relationship_name, &load_block) ⇒ Direct

Returns a new instance of Direct.

Parameters:

  • relationship_name (Symbol)

    used for building cache key. Also if the ‘load_block` param is `nil` the loader will just call `relationship_name` method on the record being processed.

  • load_block (Proc)

    If present the loader will call this block when evaluating the data.



14
15
16
17
# File 'lib/ams_lazy_relationships/loaders/direct.rb', line 14

def initialize(relationship_name, &load_block)
  @relationship_name = relationship_name
  @load_block = load_block
end