Module: Facebooker::Rails::BackwardsCompatibleParamChecks

Included in:
ActionController::AbstractRequest, ActionController::UrlRewriter, ActionDispatch::Request, Controller
Defined in:
lib/facebooker/rails/backwards_compatible_param_checks.rb

Instance Method Summary collapse

Instance Method Details

#one_or_true(value) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/facebooker/rails/backwards_compatible_param_checks.rb', line 3

def one_or_true( value )
  case value
    when String then
      value == "1"
    when Numeric then
      value.to_f == 1.0
    when TrueClass then
      true
    else
      false
  end
end

#zero_or_false(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/facebooker/rails/backwards_compatible_param_checks.rb', line 16

def zero_or_false( value )
  case value
    when String then
      value.empty? || value == "0"
    when Numeric then
      value.to_f == 0.0
    when FalseClass then
      true
    when NilClass then
      true
    else
      false
  end
end