Class: Streamer::Functors::Functor

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, options)
  @payload = payload
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/streamer/functors/functor.rb', line 5

def options
  @options
end

#payloadObject (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

#callObject



11
12
13
# File 'lib/streamer/functors/functor.rb', line 11

def call
  Module.const_get(class_name).new(payload, options).call
end

#class_nameObject



15
16
17
# File 'lib/streamer/functors/functor.rb', line 15

def class_name
  "Streamer::Functors::#{type_name}"
end

#type_nameObject



19
20
21
# File 'lib/streamer/functors/functor.rb', line 19

def type_name
  options.fetch(:type).to_s.split('_').map(&:capitalize).join
end