Sha256: e3dc04afce85fbffb6c8f8e74d24b409730674bf1498877bcd0a4b81c992b7b2

Contents?: true

Size: 780 Bytes

Versions: 89

Compression:

Stored size: 780 Bytes

Contents

class RailsOps::Hookup::DSL
  attr_reader :hooks

  def initialize(&block)
    @current_target            = nil
    @validator                 = nil
    @hooks                     = ActiveSupport::OrderedHash.new

    RailsOps::ScopedEnv.new(self, [:run]).instance_exec(&block)
  end

  def run(target, &block)
    @current_target = target
    RailsOps::ScopedEnv.new(self, [:on]).instance_exec(&block)
    @current_target = nil
  end

  def on(source, event = :after_run)
    @hooks[source] ||= ActiveSupport::OrderedHash.new
    @hooks[source][event] ||= []
    @hooks[source][event] << RailsOps::Hookup::Hook.new(source, event, @current_target)
  end

  def validate!
    @validator = RailsOps::Hookup::DSLValidator.new @hooks
    @validator.validate!
    @validator
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
rails_ops-1.1.12 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.11 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.10 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.9 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.8 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.7 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.6 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.5 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.4 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.3 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.2 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.1 lib/rails_ops/hookup/dsl.rb
rails_ops-1.1.0 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.21 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.20 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.19 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.18 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.17 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.16 lib/rails_ops/hookup/dsl.rb
rails_ops-1.0.15 lib/rails_ops/hookup/dsl.rb