Class: Parameters::Types::Proc
- Defined in:
- lib/parameters/types/proc.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
The callback that will coerce values.
Instance Method Summary collapse
-
#coerce(value) ⇒ ::Object
Coerces the value using the callback.
-
#initialize(callback) ⇒ Proc
constructor
Creates a new Proc type.
Methods inherited from Type
#<, #<=, #==, ===, #===, coerce, #to_ruby, to_ruby
Constructor Details
#initialize(callback) ⇒ Proc
Creates a new Proc type.
16 17 18 |
# File 'lib/parameters/types/proc.rb', line 16 def initialize(callback) @callback = callback end |
Instance Attribute Details
#callback ⇒ Object (readonly)
The callback that will coerce values
8 9 10 |
# File 'lib/parameters/types/proc.rb', line 8 def callback @callback end |
Instance Method Details
#coerce(value) ⇒ ::Object
Coerces the value using the callback.
29 30 31 |
# File 'lib/parameters/types/proc.rb', line 29 def coerce(value) @callback.call(value) end |