Sha256: 62c533a75b4d7afd3dec2adfee0b6ab5ad16933fde8670025a73179d9e69a2ad
Contents?: true
Size: 501 Bytes
Versions: 1
Compression:
Stored size: 501 Bytes
Contents
class Caseable attr_reader :object def self.execute(result, &block) new(result).execute(result, &block) end def initialize(object) @object = object end def execute(original_result, &block) block.call(self) case_blocks.reduce(original_result) { |result, case_block| case_block.call(result) } end def method_missing(method, &block) case_blocks << block if object.send(method) case_blocks end private def case_blocks @_case_blocks ||= [] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cases-1.0.0 | lib/cases/caseable.rb |