Class: Caffeinate::Dripper::DripCollection
- Inherits:
-
Object
- Object
- Caffeinate::Dripper::DripCollection
- Includes:
- Enumerable
- Defined in:
- lib/caffeinate/dripper/drip_collection.rb
Overview
A collection of Drip objects for a ‘Caffeinate::Dripper`
Constant Summary collapse
- VALID_DRIP_OPTIONS =
[:mailer_class, :step, :delay, :every, :start, :using, :mailer, :at, :on].freeze
Instance Method Summary collapse
- #[](val) ⇒ Object
- #each(&block) ⇒ Object
- #for(action) ⇒ Object
-
#initialize(dripper) ⇒ DripCollection
constructor
A new instance of DripCollection.
-
#register(action, options, &block) ⇒ Object
Register the drip.
- #size ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(dripper) ⇒ DripCollection
Returns a new instance of DripCollection.
11 12 13 14 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 11 def initialize(dripper) @dripper = dripper @drips = {} end |
Instance Method Details
#[](val) ⇒ Object
39 40 41 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 39 def [](val) @drips[val] end |
#each(&block) ⇒ Object
27 28 29 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 27 def each(&block) @drips.each { |action_name, drip| block.call(action_name, drip) } end |
#for(action) ⇒ Object
16 17 18 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 16 def for(action) @drips[action.to_sym] end |
#register(action, options, &block) ⇒ Object
Register the drip
21 22 23 24 25 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 21 def register(action, , &block) = (action, ) @drips[action.to_sym] = ::Caffeinate::Drip.new(@dripper, action, , &block) end |
#size ⇒ Object
35 36 37 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 35 def size @drips.size end |
#values ⇒ Object
31 32 33 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 31 def values @drips.values end |