Sha256: fe0186c9abdfe9df4626f23e5902bcc658bc47baec2a6c8486ef008bdd2afa72

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

module Lotus
  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

2 entries across 2 versions & 1 rubygems

Version Path
lotusrb-0.6.1 lib/lotus/config/framework_configuration.rb
lotusrb-0.6.0 lib/lotus/config/framework_configuration.rb