Class: Transflow::Publisher::Curried

Inherits:
Transflow::Publisher show all
Defined in:
lib/transflow/publisher.rb

Instance Attribute Summary collapse

Attributes inherited from Transflow::Publisher

#name, #op

Instance Method Summary collapse

Methods inherited from Transflow::Publisher

#curry

Constructor Details

#initialize(publisher, curry_args = []) ⇒ Curried

Returns a new instance of Curried.



18
19
20
21
22
# File 'lib/transflow/publisher.rb', line 18

def initialize(publisher, curry_args = [])
  @publisher = publisher
  @arity = publisher.arity
  @curry_args = curry_args
end

Instance Attribute Details

#arityObject (readonly)

Returns the value of attribute arity.



14
15
16
# File 'lib/transflow/publisher.rb', line 14

def arity
  @arity
end

#curry_argsObject (readonly)

Returns the value of attribute curry_args.



16
17
18
# File 'lib/transflow/publisher.rb', line 16

def curry_args
  @curry_args
end

#publisherObject (readonly)

Returns the value of attribute publisher.



12
13
14
# File 'lib/transflow/publisher.rb', line 12

def publisher
  @publisher
end

Instance Method Details

#call(*args) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/transflow/publisher.rb', line 24

def call(*args)
  all_args = curry_args + args

  if all_args.size == arity
    publisher.call(*all_args)
  else
    self.class.new(publisher, all_args)
  end
end

#subscribe(*args) ⇒ Object



34
35
36
# File 'lib/transflow/publisher.rb', line 34

def subscribe(*args)
  publisher.subscribe(*args)
end