Class: J8::Consumer

Inherits:
Object show all
Includes:
Common
Defined in:
lib/j8/consumer.rb

Instance Method Summary collapse

Methods included from Common

callable_from_proc, from_callable, from_callable_class, initialize, lambda?, make_lambda, raise_unless_lambda

Instance Method Details

#accept(o) ⇒ Object



7
8
9
# File 'lib/j8/consumer.rb', line 7

def accept(o)
  @callable.call(o)
end

#then(after = nil, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/j8/consumer.rb', line 11

def then(after = nil, &block)
  callable = from_callable(after, block)

  J8::Consumer.new(
    lambda do |o|
      accept(o)
      callable.accept(o)
    end
  )
end