Class: Wukong::Processor::Limit
- Inherits:
-
Filter
- Object
- Hanuman::Stage
- Wukong::Processor
- Filter
- Wukong::Processor::Limit
- Defined in:
- lib/wukong/widget/filters.rb
Overview
A widget which only lets a certain number of records through.
Constant Summary
Constants inherited from Wukong::Processor
Instance Attribute Summary collapse
-
#count ⇒ Object
The current record count.
Attributes included from Hanuman::StageInstanceMethods
Instance Method Summary collapse
-
#select?(record) ⇒ true, false
Select a record only if we're below the max count.
-
#setup ⇒ Object
Initializes the record count to zero.
Methods inherited from Filter
Methods inherited from Wukong::Processor
configure, description, #finalize, #perform_action, #process, #receive_action, #stop
Methods included from Logging
Methods inherited from Hanuman::Stage
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Methods included from Hanuman::StageInstanceMethods
#add_stage_link, #linkable_name, #root
Instance Attribute Details
#count ⇒ Object
The current record count.
247 248 249 |
# File 'lib/wukong/widget/filters.rb', line 247 def count @count end |
Instance Method Details
#select?(record) ⇒ true, false
Select a record only if we're below the max count. Increments the count for this widget.
259 260 261 262 263 |
# File 'lib/wukong/widget/filters.rb', line 259 def select?(record) keep = (max ? @count < max : true) @count += 1 keep end |
#setup ⇒ Object
Initializes the record count to zero.
250 251 252 |
# File 'lib/wukong/widget/filters.rb', line 250 def setup self.count = 0 end |