Class: FriendlyRoutes::Params::BooleanParams
- Defined in:
- lib/friendly_routes/params/boolean_params.rb
Instance Attribute Summary collapse
-
#false ⇒ Object
Returns the value of attribute false.
-
#true ⇒ Object
Returns the value of attribute true.
Attributes inherited from Base
Instance Method Summary collapse
- #constraints ⇒ Object
-
#initialize(name, options, optional: true) ⇒ BooleanParams
constructor
A new instance of BooleanParams.
- #parse(value) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, options, optional: true) ⇒ BooleanParams
Returns a new instance of BooleanParams.
8 9 10 11 12 13 |
# File 'lib/friendly_routes/params/boolean_params.rb', line 8 def initialize(name, , optional: true) check_params() super(:boolean, name, optional) @true = [:true] @false = [:false] end |
Instance Attribute Details
#false ⇒ Object
Returns the value of attribute false.
6 7 8 |
# File 'lib/friendly_routes/params/boolean_params.rb', line 6 def false @false end |
#true ⇒ Object
Returns the value of attribute true.
6 7 8 |
# File 'lib/friendly_routes/params/boolean_params.rb', line 6 def true @true end |
Instance Method Details
#constraints ⇒ Object
15 16 17 |
# File 'lib/friendly_routes/params/boolean_params.rb', line 15 def constraints Regexp.new "#{@true}|#{@false}" end |
#parse(value) ⇒ Object
19 20 21 |
# File 'lib/friendly_routes/params/boolean_params.rb', line 19 def parse(value) value == @true end |