class Parameters::Types::Proc

Attributes

callback[R]

The callback that will coerce values

Public Class Methods

new(callback) click to toggle source

Creates a new Proc type.

@param [#call] callback

The callback that will handle the actual coercion.
# File lib/parameters/types/proc.rb, line 16
def initialize(callback)
  @callback = callback
end

Public Instance Methods

coerce(value) click to toggle source

Coerces the value using the callback.

@param [::Object] value

The value to coerce.

@return [::Object]

The result of the callback.
# File lib/parameters/types/proc.rb, line 29
def coerce(value)
  @callback.call(value)
end