Class: Transflow::Publisher::Curried
- Inherits:
-
Transflow::Publisher
- Object
- Transflow::Publisher
- Transflow::Publisher::Curried
- Defined in:
- lib/transflow/publisher.rb
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#curry_args ⇒ Object
readonly
Returns the value of attribute curry_args.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
Attributes inherited from Transflow::Publisher
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(publisher, curry_args = []) ⇒ Curried
constructor
A new instance of Curried.
- #subscribe(*args) ⇒ Object
Methods inherited from Transflow::Publisher
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
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
35 36 37 |
# File 'lib/transflow/publisher.rb', line 35 def arity @arity end |
#curry_args ⇒ Object (readonly)
Returns the value of attribute curry_args.
37 38 39 |
# File 'lib/transflow/publisher.rb', line 37 def curry_args @curry_args end |
#publisher ⇒ Object (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 |