class Yukata::Coercion
This wraps the block that is provided when you register a coercion.
@author Matthew A. Johnston
Constants
- PASS_THROUGH
Just passes the object on through
Public Class Methods
new(origin, target, &block)
click to toggle source
@param origin [Class] the class that the object is @param target [Class] the class you wish to coerce to
# File lib/yukata/coercion.rb, line 11 def initialize(origin, target, &block) @origin = origin @target = target @block = block_given? ? block : PASS_THROUGH end
Public Instance Methods
call(object)
click to toggle source
Calls the coercion
@return [Object]
# File lib/yukata/coercion.rb, line 20 def call(object) @block.call(object, @target) end