Class: CubanLinx::Collaborator

Inherits:
Object
  • Object
show all
Defined in:
lib/cuban_linx/collaborator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, function) ⇒ Collaborator

Returns a new instance of Collaborator.



3
4
5
6
# File 'lib/cuban_linx/collaborator.rb', line 3

def initialize(context, function)
  @context = context
  @function = function
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/cuban_linx/collaborator.rb', line 8

def context
  @context
end

#functionObject (readonly)

Returns the value of attribute function.



8
9
10
# File 'lib/cuban_linx/collaborator.rb', line 8

def function
  @function
end

Instance Method Details

#call(payload) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/cuban_linx/collaborator.rb', line 10

def call(payload)
  case payload.status
  in :ok
    context.instance_exec(payload, &function).then do |result|
      Payload.new(*handle(payload, result))
    end
  in :no_op | :error
    payload
  end
end