class Lab42::Stream::Behavior
Public Class Methods
const(const_rval)
click to toggle source
# File lib/lab42/stream/behavior.rb, line 17 def const(const_rval) __const_hash__.fetch!(const_rval, new{ |*_| const_rval}) end
make(*args, &blk)
click to toggle source
# File lib/lab42/stream/behavior.rb, line 21 def make(*args, &blk) if blk raise ArgumentError, "cannot specify behavior with block and args: #{args.inspect}" unless args.empty? blk else _make_from_args( args ) end end
make1(*args, &blk)
click to toggle source
# File lib/lab42/stream/behavior.rb, line 30 def make1(*args, &blk) if blk blk else _make_from_args( args ) end end
new( &blk )
click to toggle source
# File lib/lab42/stream/behavior.rb, line 7 def initialize( &blk ) @behavior = blk end
Private Class Methods
__const_hash__()
click to toggle source
# File lib/lab42/stream/behavior.rb, line 55 def __const_hash__ @__const_hash__ ||= {} end
_curry(args)
click to toggle source
# File lib/lab42/stream/behavior.rb, line 49 def _curry(args) -> ( *a ) do args.first.(*(args.drop(1)+a)) end end
_make_from_args( args )
click to toggle source
# File lib/lab42/stream/behavior.rb, line 39 def _make_from_args( args ) if args.first.respond_to?( :call ) _curry( args ) else -> (rcv, *a) do rcv.send(*(args + a)) end end end
Public Instance Methods
call( *args )
click to toggle source
# File lib/lab42/stream/behavior.rb, line 11 def call( *args ) @behavior.( *args ) end