Sha256: b297ef0b8e24b57ccbf629bc25b99f4f305cf6b51916352d414cdeaf461367c1

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

module Daijobu
  class NamespaceProxy
    
    @@default_separator = ':'
    def self.default_separator
      @@default_separator
    end
    
    def self.default_separator=(separator)
      @@default_separator = separator
    end
    
    def initialize(owner, namespace, separator = @@default_separator)
      @owner = owner
      @namespace = namespace.to_s
      @separator = separator
    end
    
    def [](key)
      @owner["#{@namespace}#{@separator}#{key}"]
    end
    
    def []=(key, value)
      @owner["#{@namespace}#{@separator}#{key}"] = value
    end
    
    def method_missing(namespace, *args)
      separator = args.shift || @@default_separator
      Daijobu::NamespaceProxy.new(@owner, "#{@namespace}#{@separator}#{namespace}", separator)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sander6-daijobu-0.2.0 lib/daijobu/namespace_proxy.rb