Sha256: b2bd213dec182b69e10e5815631353e335ecd5f854799887e6be9c9e6a69bed1
Contents?: true
Size: 925 Bytes
Versions: 2
Compression:
Stored size: 925 Bytes
Contents
module Brototype # Bromise... it's stronger than a Promise class Bromise def initialize(object, method=nil, args=[]) @object = object @method = method @args = args.count > 1 ? args.slice(1) : [] end def but_when_i_do(callback=nil) return_value = nil if @object.respond_to? @method return_value = @object.send(@method) else return_value = Bro.new(@object).i_can_haz @method end if return_value (callback || (lambda {|x|1})).call return_value end end def here_come_the_errors(callback=nil) if @object.respond_to? @method begin @object.send(@method) rescue Exception => e callback.call e end else callback(@method + ' is not a proc'); end end def errors_are_coming self.here_come_the_errors.call end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brototype-0.9.3 | lib/brototype/bromise.rb |
brototype-0.9.1 | lib/brototype/bromise.rb |