Class: MiniCamel::Processor::ExposeField

Inherits:
Base
  • Object
show all
Defined in:
lib/mini_camel/processor/expose_field.rb

Instance Method Summary collapse

Instance Method Details

#call(exchange) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mini_camel/processor/expose_field.rb', line 11

def call(exchange)
  from_value  = exchange.context_fetch(from)

  if from_value.is_a?(Hash)
    field_value = from_value[field]
  else
    if !from_value.respond_to?(field)
      raise ArgumentError, "#{from} does not respond to #{field}"
    end

    field_value = from_value.public_send(field)
  end

  exchange.update_context(as => field_value)
end