Module: FitApi::Router::Params

Defined in:
lib/fit_api/router/params.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args, &block) ⇒ Object (private)



32
33
34
35
# File 'lib/fit_api/router/params.rb', line 32

def method_missing(method_sym, *args, &block)
  attr = self.key?(method_sym) ? method_sym : method_sym.to_s
  self[attr]
end

Instance Method Details

#[](key) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fit_api/router/params.rb', line 6

def [](key)
  value = super(key.to_s)
  if value.is_a?(Hash)
    value.extend(Params)
  end
  value
end

#except(*blacklist) ⇒ Object



14
15
16
17
# File 'lib/fit_api/router/params.rb', line 14

def except(*blacklist)
  blacklist.map!(&:to_s)
  build(keys - blacklist)
end

#permit(*whitelist) ⇒ Object



19
20
21
22
# File 'lib/fit_api/router/params.rb', line 19

def permit(*whitelist)
  whitelist.map!(&:to_s)
  build(keys & whitelist)
end