Module: Flarg

Extended by:
ActiveSupport::Concern
Defined in:
lib/flarg.rb,
lib/flarg/railtie.rb,
lib/flarg/version.rb

Defined Under Namespace

Modules: ClassMethods Classes: Railtie

Constant Summary collapse

NAMESPACE =
"#{name.downcase}_"
VERSION =
'0.0.2'

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



39
40
41
42
43
44
45
# File 'lib/flarg.rb', line 39

def method_missing(name,*args)
  if name.to_s =~ /=$/
    store(name.to_s.sub(/=$/,""),args.first)
  else
    retrieve(name)
  end
end

Instance Method Details

#[](key) ⇒ Object Also known as: retrieve



19
20
21
22
23
# File 'lib/flarg.rb', line 19

def [](key)
  Rails.application.config.send(convert_key(key))
rescue NoMethodError
  nil
end

#[]=(key, value) ⇒ Object Also known as: store



27
28
29
# File 'lib/flarg.rb', line 27

def []=(key,value)
  Rails.application.config.send("#{convert_key(key)}=",value)
end