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.



39
40
41
42
43
# File 'lib/transflow/publisher.rb', line 39

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.



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

def arity
  @arity
end

#curry_argsObject (readonly)

Returns the value of attribute curry_args.



37
38
39
# File 'lib/transflow/publisher.rb', line 37

def curry_args
  @curry_args
end

#publisherObject (readonly)

Returns the value of attribute publisher.



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

def publisher
  @publisher
end

Instance Method Details

#call(*args) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/transflow/publisher.rb', line 45

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



55
56
57
# File 'lib/transflow/publisher.rb', line 55

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