Sha256: d12378c41007e075b02c54680eced59e96456c62dfb77e63267483e82783b090

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 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

3 entries across 3 versions & 1 rubygems

Version Path
lamby-4.0.0 lib/lamby/config.rb
lamby-4.0.0.pre1 lib/lamby/config.rb
lamby-4.0.0.beta6 lib/lamby/config.rb