Sha256: 3b5403397a94fa7be6bf1dfaf8c0c4ea0dce781e19a1dd6411dc19c34a5f84fd

Contents?: true

Size: 1001 Bytes

Versions: 5

Compression:

Stored size: 1001 Bytes

Contents

module Lamby
  module Config

    def configure
      yield(config)
      config
    end

    def reconfigure
      config.reconfigure { |c| yield(c) if block_given? }
    end

    def config
      @config ||= Configuration.new
    end

    extend self

  end

  class Configuration

    def initialize
      initialize_defaults
    end

    def reconfigure
      instance_variables.each { |var| instance_variable_set var, nil }
      initialize_defaults
      yield(self) if block_given?
      self
    end

    def rack_app
      @rack_app ||= Rack::Builder.new { run Rails.application }.to_app
    end

    def rack_app=(app)
      @rack_app = app
    end

    def initialize_defaults
      @rack_app = nil
      @event_bridge_handler = lambda { |event, context| puts(event) }
    end

    def event_bridge_handler
      @event_bridge_handler
    end

    def event_bridge_handler=(func)
      @event_bridge_handler = func
    end

    def runner_patterns
      Runner::PATTERNS
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lamby-4.0.0.beta5 lib/lamby/config.rb
lamby-4.0.0.beta4 lib/lamby/config.rb
lamby-4.0.0.beta3 lib/lamby/config.rb
lamby-4.0.0.beta2 lib/lamby/config.rb
lamby-4.0.0.beta1 lib/lamby/config.rb