Class: Wukong::Processor::Select

Inherits:
Filter show all
Defined in:
lib/wukong/widget/filters.rb

Overview

A widget useful for creating filters on the fly in a dataflow.

When writing a filtering processor out as a class, just use the DSL for creating processors:

When in a dataflow, sometimes it's easier to create a processor like this on the fly.

Examples:

Creating a select filter the usual way


Wukong.processor(:my_filter, Wukong::Processor::Filter) do
  def select? record
    record.length > 3
  end
end

Creating a select filter on the fly in a dataflow


Wukong.dataflow(:my_flow) do
  ... | select { |record| record.length > 3 } | ...
end

See Also:

Constant Summary

Constants inherited from Wukong::Processor

SerializerError

Instance Attribute Summary

Attributes included from Hanuman::StageInstanceMethods

#graph

Instance Method Summary collapse

Methods inherited from Filter

#process, #reject?

Methods inherited from Wukong::Processor

configure, description, #finalize, #perform_action, #process, #receive_action, #setup, #stop

Methods included from Logging

included

Methods inherited from Hanuman::Stage

#clone

Methods included from Hanuman::StageClassMethods

#builder, #label, #register, #set_builder

Methods included from Hanuman::StageInstanceMethods

#add_link, #linkable_name, #root

Instance Method Details

#select?(record) ⇒ true, false

Selects the given record by delegating to the perform_action method, which will automatically be populating by the block used to create this filter in the dataflow DSL.

Parameters:

  • record (Object)

Returns:

  • (true, false)

See Also:



353
354
355
# File 'lib/wukong/widget/filters.rb', line 353

def select?(record)
  perform_action(record)
end