Class: AdminAssistant::Builder::ColumnConfigLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_assistant/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(column_name, settingses, admin_assistant) ⇒ ColumnConfigLookup

Returns a new instance of ColumnConfigLookup.



49
50
51
52
# File 'lib/admin_assistant/builder.rb', line 49

def initialize(column_name, settingses, admin_assistant)
  @column_name, @settingses, @admin_assistant =
      column_name, settingses, admin_assistant
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/admin_assistant/builder.rb', line 54

def method_missing(meth, *args)
  match = meth
  if match.to_s =~ /^(.*)=$/
    match = $1.to_sym
  elsif match.to_s =~ /^(.*)\?$/
    match = $1.to_sym
  end
  setting = @settingses.detect { |setting|
    setting.column_config_fields.keys.include?(match)
  }
  if setting
    setting[@column_name].send(meth, *args)
  else
    super
  end
end