Module: Planify::Plans
- Defined in:
- lib/planify/plans.rb
Class Method Summary collapse
-
.all ⇒ Array
Returns the list of plans.
-
.clear ⇒ Object
Removes all currently defined plans.
-
.define(name, &block) ⇒ Planify::Plan
Defines a new plan, evaluating the given block on the new plan instance.
-
.get(name) ⇒ Planify::Plan
Gets a plan by name.
Class Method Details
.all ⇒ Array
Returns the list of plans
30 31 32 |
# File 'lib/planify/plans.rb', line 30 def self.all @plans.values end |
.clear ⇒ Object
Removes all currently defined plans
35 36 37 |
# File 'lib/planify/plans.rb', line 35 def self.clear @plans.clear end |
.define(name, &block) ⇒ Planify::Plan
Defines a new plan, evaluating the given block on the new plan instance.
9 10 11 12 13 14 |
# File 'lib/planify/plans.rb', line 9 def self.define(name, &block) plan = Plan.new plan.instance_eval(&block) if block_given? @plans[name] = plan end |
.get(name) ⇒ Planify::Plan
Gets a plan by name
20 21 22 23 24 25 26 |
# File 'lib/planify/plans.rb', line 20 def self.get(name) begin @plans.fetch(name) rescue raise ArgumentError, "A plan named '#{name}' is not defined" end end |