Module: CarryOut

Defined in:
lib/carry_out/cloaker.rb,
lib/carry_out.rb,
lib/carry_out/unit.rb,
lib/carry_out/error.rb,
lib/carry_out/result.rb,
lib/carry_out/version.rb,
lib/carry_out/plan/node.rb,
lib/carry_out/plan/guard.rb,
lib/carry_out/plan_runner.rb,
lib/carry_out/configurator.rb,
lib/carry_out/plan_builder.rb,
lib/carry_out/result_error.rb,
lib/carry_out/plan/node_result.rb,
lib/carry_out/plan/node_context.rb,
lib/carry_out/plan/guard_context.rb,
lib/carry_out/configured_instance.rb

Overview

A Closure Is Not Always A Closure In Ruby - Alan Skorkin www.skorks.com/2013/03/a-closure-is-not-always-a-closure-in-ruby/

Defined Under Namespace

Modules: Cloaker, Plan Classes: Configurator, ConfiguredInstance, Error, PlanBuilder, PlanRunner, Result, ResultError, Unit

Constant Summary collapse

VERSION =
"1.3.3"

Class Method Summary collapse

Class Method Details

.call_unit(*args, &block) ⇒ Object



13
14
15
# File 'lib/carry_out.rb', line 13

def self.call_unit(*args, &block)
  PlanRunner.call_unit(*args, &block)
end

.configurationObject



17
18
19
# File 'lib/carry_out.rb', line 17

def self.configuration
  @configuration ||= {}
end

.configure(&block) ⇒ Object



21
22
23
# File 'lib/carry_out.rb', line 21

def self.configure(&block)
  Configurator.new(configuration).instance_eval(&block)
end

.plan(options = {}, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/carry_out.rb', line 25

def self.plan(options = {}, &block)
  merged_options = Hash.new.merge(configuration).merge(options)
  plan = PlanBuilder.build(merged_options, &block)

  Proc.new do |context = nil, &block| 
    PlanRunner.call(plan, context).tap do |result|
      block.call(result) unless block.nil?
    end
  end
end

.with_configuration(options = {}) ⇒ Object



36
37
38
# File 'lib/carry_out.rb', line 36

def self.with_configuration(options = {})
  ConfiguredInstance.new(options)
end