Method: AdminData::Util.custom_value_for_column

Defined in:
lib/admin_data/util.rb

.custom_value_for_column(column, model) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/admin_data/util.rb', line 12

def self.custom_value_for_column(column, model)
  # some would say that if I use try method then I will not be raising exception and
  # I agree. However in this case for clarity I would prefer to not to have try after each call
  begin
    column_name = column.respond_to?(:name) ? column.name : column
    tmp = AdminData.config.column_settings[model.class.name.to_s]
    _proc = tmp.fetch(column_name.intern)
    _proc.call(model)
  rescue
    model.send(column_name)
  end
end