Sha256: 8ad67aeaa66a3c17ebee0f363798d677ac059aca078e5ff234bbdf76dad28722
Contents?: true
Size: 403 Bytes
Versions: 15
Compression:
Stored size: 403 Bytes
Contents
require 'myrrha/coerce' class Foo def initialize(arg) @arg = arg end end MyRules = Myrrha::Coerce.dup.append do |r| r.coercion(Symbol, Foo) do |value, _| Foo.new(value) end end begin Myrrha::Coerce.apply(:hello, Foo) raise "Unexpected" rescue Myrrha::Error # => Myrrha::Error: Unable to coerce `hello` to Foo end MyRules.apply(:hello, Foo) # => #<Foo:0x8b7d254 @arg=:hello>
Version data entries
15 entries across 15 versions & 1 rubygems