Sha256: caeee97fd3426a066125cf77d869dfbead0b07bd53da40e90d53f1826c9b3021

Contents?: true

Size: 963 Bytes

Versions: 21

Compression:

Stored size: 963 Bytes

Contents

module Hanami
  # @api private
  module Config
    # Collects all the settings for a given framework configuration and then
    # forwards them when the application is loaded.
    #
    # @since 0.2.0
    # @api private
    class FrameworkConfiguration < BasicObject
      # @since 0.2.0
      # @api private
      def initialize(&blk)
        @blocks   = [blk || ::Proc.new { }]
        @settings = []
      end

      # @since 0.2.0
      # @api private
      def __apply(configuration)
        @blocks.compact.each do |blk|
          configuration.instance_eval(&blk)
        end

        @settings.each do |(m, args, blk)|
          configuration.public_send(m, *args, &blk)
        end
      end

      # @since 0.6.0
      # @api private
      def __add(&blk)
        @blocks << blk
        self
      end

      # @since 0.2.0
      # @api private
      def method_missing(m, *args, &blk)
        @settings.push([m, args, blk])
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hanami-1.3.5 lib/hanami/config/framework_configuration.rb
hanami-1.3.4 lib/hanami/config/framework_configuration.rb
hanami-1.3.3 lib/hanami/config/framework_configuration.rb
hanami-1.3.2 lib/hanami/config/framework_configuration.rb
hanami-1.3.1 lib/hanami/config/framework_configuration.rb
hanami-1.3.0 lib/hanami/config/framework_configuration.rb
hanami-1.3.0.beta1 lib/hanami/config/framework_configuration.rb
hanami-1.2.0 lib/hanami/config/framework_configuration.rb
hanami-1.2.0.rc2 lib/hanami/config/framework_configuration.rb
hanami-1.2.0.rc1 lib/hanami/config/framework_configuration.rb
hanami-1.2.0.beta2 lib/hanami/config/framework_configuration.rb
hanami-1.2.0.beta1 lib/hanami/config/framework_configuration.rb
hanami-1.1.1 lib/hanami/config/framework_configuration.rb
hanami-1.1.0 lib/hanami/config/framework_configuration.rb
hanami-1.1.0.rc1 lib/hanami/config/framework_configuration.rb
hanami-1.1.0.beta3 lib/hanami/config/framework_configuration.rb
hanami-1.1.0.beta2 lib/hanami/config/framework_configuration.rb
hanami-1.1.0.beta1 lib/hanami/config/framework_configuration.rb
hanami-1.0.0 lib/hanami/config/framework_configuration.rb
hanami-1.0.0.rc1 lib/hanami/config/framework_configuration.rb