Sha256: 5001f50778c50e721b0054a5155325506586ec78b15d09166884e2df15d673bf

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

module Peony
  class Settings
    attr_reader :current_scope, :root_scope

    def initialize
      @current_scope = @root_scope = Scope.new(:root)
    end

    def with_scope(name)
      original_scope = current_scope
      begin
        @current_scope = original_scope.new_scope(name)
        yield
      ensure
        @current_scope = original_scope
      end
    end

    def method_missing(method, *args, &block)
      if current_scope.respond_to?(method, false)
        current_scope.__send__(method, *args, &block)
      else
        super
      end
    end

    def respond_to_missing?(method, include_all = true)
      current_scope.respond_to?(method, include_all)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
peony-0.3.1 lib/peony/settings.rb
peony-0.3.0 lib/peony/settings.rb