Class: SuperFinder::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/super_finder/config.rb

Constant Summary collapse

@@default_options =
{
  :url              => {
    :name_prefix      => nil,
    :action           => :show
  },
  :models           => [],
  :scoper           => {
    :column => nil,
    :getter => nil
  },
  :before_filters   => []
}

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/super_finder/config.rb', line 30

def method_missing(method, *args)
  if method.to_s.ends_with?('=')
    attributes[method.to_s[0..-2].to_sym] = args.first
  else
    attributes[method]
  end
end

Instance Method Details

#attributesObject



22
23
24
# File 'lib/super_finder/config.rb', line 22

def attributes
  @attributes ||= @@default_options.clone # only called once 
end

#reset_attributesObject



26
27
28
# File 'lib/super_finder/config.rb', line 26

def reset_attributes
  @attributes = nil
end

#to_sObject



38
39
40
# File 'lib/super_finder/config.rb', line 38

def to_s
  attributes.inspect
end