Class: Streamer::Functors::Functor
- Inherits:
-
Object
- Object
- Streamer::Functors::Functor
- Defined in:
- lib/streamer/functors/functor.rb
Overview
Functor is responsible for creating the functions that the stream uses.
Direct Known Subclasses
Average, Count, Divide, Eq, Group, Gt, Gte, Least, ListFilter, Lookup, Lt, Lte, Member, Multiply, Subtract, Sum
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #call ⇒ Object
- #class_name ⇒ Object
-
#initialize(payload, options) ⇒ Functor
constructor
A new instance of Functor.
- #type_name ⇒ Object
Constructor Details
#initialize(payload, options) ⇒ Functor
Returns a new instance of Functor.
6 7 8 9 |
# File 'lib/streamer/functors/functor.rb', line 6 def initialize(payload, ) @payload = payload @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/streamer/functors/functor.rb', line 5 def @options end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/streamer/functors/functor.rb', line 5 def payload @payload end |
Instance Method Details
#call ⇒ Object
11 12 13 |
# File 'lib/streamer/functors/functor.rb', line 11 def call Module.const_get(class_name).new(payload, ).call end |
#class_name ⇒ Object
15 16 17 |
# File 'lib/streamer/functors/functor.rb', line 15 def class_name "Streamer::Functors::#{type_name}" end |
#type_name ⇒ Object
19 20 21 |
# File 'lib/streamer/functors/functor.rb', line 19 def type_name .fetch(:type).to_s.split('_').map(&:capitalize).join end |