Module: Monolens::Lens::FetchSupport

Included in:
Monolens::Lens, Options
Defined in:
lib/monolens/lens/fetch_support.rb

Instance Method Summary collapse

Instance Method Details

#fetch_on(attr, arg, default = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/monolens/lens/fetch_support.rb', line 4

def fetch_on(attr, arg, default = nil)
  if arg.key?(attr)
    [ attr, arg[attr] ]
  elsif arg.key?(attr_s = attr.to_s)
    [ attr_s, arg[attr_s] ]
  elsif arg.key?(attr_sym = attr.to_sym)
    [ attr_sym, arg[attr_sym] ]
  elsif default
    [ attr, default ]
  else
    nil
  end
end