Sha256: d71251f4df9132bc3aac12266f23496173fcda2a53280bb7c7d66048f9bf9a0d

Contents?: true

Size: 307 Bytes

Versions: 5

Compression:

Stored size: 307 Bytes

Contents

module EasyCommand
  module Chainable
    def then(other)
      if success?
        other.call(result)
      else
        self
      end
    end
    alias_method :|, :then

    def self.included(klass)
      klass.define_method(:call) { self } unless klass.instance_methods.include? :call
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
easy_command-1.0.1 lib/easy_command/chainable.rb
easy_command-1.0.0 lib/easy_command/chainable.rb
easy_command-1.0.0.pre.rc3 lib/easy_command/chainable.rb
easy_command-1.0.0.pre.rc2 lib/easy_command/chainable.rb
easy_command-1.0.0.pre.rc1 lib/easy_command/chainable.rb