class RFlow::Components::RubyProcFilter
Component
that filters messages based on Ruby defined in the RFlow
config file. Inbound messages will be sent out {filtered} if the predicate returns truthy, {dropped} if it returns falsey, or {errored} if it raises an exception.
Accept config parameter filter_proc_string
which is the text of a lambda
receiving a message message
. For example, +message.data.data_object > 2+.
Public Instance Methods
configure!(config)
click to toggle source
RFlow-called method at startup. @param config [Hash] configuration from the RFlow
config file @return [void]
# File lib/rflow/components/ruby_proc_filter.rb, line 31 def configure!(config) @filter_proc = eval("lambda {|message| #{config['filter_proc_string']} }") end
process_message(input_port, input_port_key, connection, message)
click to toggle source
RFlow-called method on message arrival. @return [void]
# File lib/rflow/components/ruby_proc_filter.rb, line 37 def process_message(input_port, input_port_key, connection, message) begin if @filter_proc.call(message) filtered.send_message message else dropped.send_message message end rescue Exception => e RFlow.logger.debug "#{self.class} Message caused exception: #{e.class}: #{e.message}: #{e.backtrace}" errored.send_message message end end