Class: IdHash

Inherits:
HashOfArrays show all
Defined in:
lib/id_hash.rb

Instance Method Summary collapse

Methods inherited from HashOfArrays

#clone, #initialize, #join, join, #sort_arrays!, #subtract

Constructor Details

This class inherits a constructor from HashOfArrays

Instance Method Details

#add(key, *values) ⇒ Object



55
56
57
58
59
# File 'lib/id_hash.rb', line 55

def add(key, *values)
  super(key, *values)
  self[key].uniq!
  self
end

#remove_entries_from_db(as_first: [], as_last: []) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/id_hash.rb', line 61

def remove_entries_from_db(as_first: [], as_last: [])
  exceptionals = as_first + as_last
  remove_from_exceptional(as_first)

  self.each do |name, ids|
    next if exceptionals.include?(name)
    remove_entries_from_array(name, ids)
  end

  remove_from_exceptional(as_last)
end

#with_table_symbolsObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/id_hash.rb', line 73

def with_table_symbols
  result = HashOfArrays.new

  self.each do |name, ids|
    symbol = Model.get_model(name).table_name.to_sym
    result[symbol] = ids
  end

  result
end