#
# Takes a lookup table with an id/label, and will make the id available via a symbol-ized label.
#
# tableobject: The table object name (e.g. table name is 'account_statuses'; table object is AccountStatus)
#
# Usage:
# @statuses = lookup_table AccountStatus
#
# If:
# :id => 1, :label => 'Registered'
# :id => 2, :label => 'Recurring'
# :id => 3, :label => 'Closed'
#
# Then:
# @statuses[:registered] => 1
# @statuses[:recurring] => 2
# @statuses[:closed] => 3
#
def lookup_table(tableobject)
collection = {}
tableobject.all.each do | entry |
collection.merge!({
# Convert the string to be more symbol-like
entry.label.underscore.split(' ').join('').camelize.downcase.intern => entry.id
})
end
return collection
end