Class: Mixture::Coerce::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/mixture/coerce/object.rb

Overview

Handles coercion of the Object class.

Constant Summary collapse

TryMethods =

Tries a set of methods on the object, before failing with a coercion error.

Returns:

proc do |*methods|
  proc do |value|
    method = methods.find { |m| value.respond_to?(m) }
    if method
      value.public_send(method)
    else
      fail CoercionError, "Could not coerce #{value.class}"
    end
  end
end

Method Summary

Methods inherited from Base

coerce_to, coercions, data_block, inherited, to, #to, type