Class: Vorpal::LookupInstructions

Inherits:
Object
  • Object
show all
Includes:
Util::ArrayHash
Defined in:
lib/vorpal/db_loader.rb

Instance Method Summary collapse

Methods included from Util::ArrayHash

#add_to_hash, #pop

Constructor Details

#initializeLookupInstructions

Returns a new instance of LookupInstructions.



75
76
77
78
# File 'lib/vorpal/db_loader.rb', line 75

def initialize
  @lookup_by_id = {}
  @lookup_by_fk = {}
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/vorpal/db_loader.rb', line 96

def empty?
  @lookup_by_id.empty? && @lookup_by_fk.empty?
end

#lookup_by_fk(config, fk_info, fk_value) ⇒ Object



84
85
86
# File 'lib/vorpal/db_loader.rb', line 84

def lookup_by_fk(config, fk_info, fk_value)
  add_to_hash(@lookup_by_fk, [config, fk_info], fk_value)
end

#lookup_by_id(config, ids) ⇒ Object



80
81
82
# File 'lib/vorpal/db_loader.rb', line 80

def lookup_by_id(config, ids)
  add_to_hash(@lookup_by_id, config, Array(ids))
end

#next_lookupObject



88
89
90
91
92
93
94
# File 'lib/vorpal/db_loader.rb', line 88

def next_lookup
  if @lookup_by_id.empty?
    pop_fk_lookup
  else
    pop_id_lookup
  end
end