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, :action_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, type = ::Caffeinate::Drip, &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
37 38 39 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 37 def [](val) @drips[val] end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 25 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, type = ::Caffeinate::Drip, &block) ⇒ Object
Register the drip
21 22 23 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 21 def register(action, , type = ::Caffeinate::Drip, &block) @drips[action.to_sym] = type.build(@dripper, action, , &block) end |
#size ⇒ Object
33 34 35 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 33 def size @drips.size end |
#values ⇒ Object
29 30 31 |
# File 'lib/caffeinate/dripper/drip_collection.rb', line 29 def values @drips.values end |