Sha256: a498e0d88d3f7ff9d5fef1a85d0674e1db2d5795081a892c17c235510ed609bf
Contents?: true
Size: 489 Bytes
Versions: 2
Compression:
Stored size: 489 Bytes
Contents
require "with_refinements" module Helloable refine(Object) do def hello puts :hello end end end module Hiable refine(Object) do def hi puts :hi end end end class Person using WithRefinements def initialize(with:) @things = Array(with) end def greet(&block) with_refinements(*@things, &block) end end a = Person.new(with: Hiable) b = Person.new(with: Helloable) a.greet do hello rescue hi end b.greet do hi rescue hello end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
with_refinements-0.5.0 | examples/greeting.rb |
with_refinements-0.4.0 | examples/greeting.rb |