Module: EasyParams
- Defined in:
- lib/easy_params.rb,
lib/easy_params/base.rb,
lib/easy_params/types.rb,
lib/easy_params/version.rb,
lib/easy_params/validation.rb,
lib/easy_params/types/struct.rb,
lib/easy_params/types/generic.rb,
lib/easy_params/types/collection.rb
Overview
EasyParams provides a simple way to define parameter classes with type coercion and validation
Defined Under Namespace
Modules: Types, Validation Classes: Base, CoercionError, Error
Constant Summary collapse
- BOOLEAN_MAP =
{ '1' => true, 't' => true, 'true' => true, 'True' => true, 'TRUE' => true, 'T' => true }.merge( { '0' => false, 'f' => false, 'false' => false, 'False' => false, 'FALSE' => false, 'F' => false } ).freeze
- VERSION =
'0.7.0'
Class Method Summary collapse
Class Method Details
.register_type(name, type = nil, &coerce_proc) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/easy_params.rb', line 22 def self.register_type(name, type = nil, &coerce_proc) if type.nil? && coerce_proc type = Types::Generic.new(name, &coerce_proc) elsif type.nil? && !coerce_proc raise ArgumentError, 'Either a type instance or a coercion block must be provided' end types[name] = type Base.define_type_method(name) end |
.types ⇒ Object
18 19 20 |
# File 'lib/easy_params.rb', line 18 def self.types @types ||= {} end |