Module: Planify::Plans

Defined in:
lib/planify/plans.rb

Class Method Summary collapse

Class Method Details

.allArray

Returns the list of plans

Returns:

  • (Array)

    an array of Planify::Plan instances



30
31
32
# File 'lib/planify/plans.rb', line 30

def self.all
  @plans.values
end

.clearObject

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.

Parameters:

  • name (String, Symbol)

    The name of the plan

Returns:



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

Parameters:

  • name (String, Symbol)

    The name of the plan

Returns:

Raises:

  • (ArgumentError)

    if a plan named name is not defined



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