Sha256: 7650f5fa7362c185d104fd6f8a355d0fff528c408bb0fd06b508d3ba150a3eb9

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Pancake
  class Stack
    inheritable_inner_classes :Configuration

    class Configuration < Pancake::Configuration::Base
    end

    # Provides access to the configuration block for the stack.
    # If a block is provided, it opens the specific configuration instances anonymous class
    # and allows you to edit it.
    # If no block is provided, it just returns the configuration object.
    #
    # :api: public
    def self.configuration(label = self, &block)
      config = Pancake.configuration.configs[label] ||= self::Configuration.new
      config.class.class_eval(&block) if block
      config
    end

    def configuration(label = self.class)
      yield self.class.configuration(label) if block_given?
      self.class.configuration(label)
    end

  end # Stack
end # Pancake

####################
# Setup the default configuration for each stack
class Pancake::Stack::Configuration
  default :router, Proc.new{ _router }, "The router for this stack"

  def _router
    @_router ||= begin
      unless stack.nil?
        r = stack.router.clone
        r.stack = stack
        r.configuration = self
        r
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pancake-0.3.0 lib/pancake/stack/configuration.rb