Class: ParamsChecker::ParamChecker::BooleanChecker

Inherits:
BaseParamChecker show all
Includes:
SimpleCommand
Defined in:
lib/params_checker/param_checker.rb

Instance Attribute Summary

Attributes inherited from BaseParamChecker

#fields, #key, #opts

Instance Method Summary collapse

Methods inherited from BaseParamChecker

#add_error, #initialize

Constructor Details

This class inherits a constructor from ParamsChecker::ParamChecker::BaseParamChecker

Instance Method Details

#callObject



275
276
277
278
279
# File 'lib/params_checker/param_checker.rb', line 275

def call
      return nil if fields[key][:allow_nil] && opts[key].nil?

    check_type && opts[key]
end

#check_typeObject



281
282
283
284
285
# File 'lib/params_checker/param_checker.rb', line 281

def check_type
    valid = opts[key].in? [true, false]
    add_error("This field's type must be boolean.") unless valid
    valid
end