Sha256: 92fd8a0eef2665c3f2038586fa63ad998b875c1126f9195f09e04c453ff0a9f9

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

module Daijobu
  class Client

    def initialize(casket, options = {})
      @adapter        = Daijobu::Adapter.get(casket)
      @read_schemes   = Daijobu::SchemeSet.new(options[:schemes] || options[:read])
      @write_schemes  = Daijobu::SchemeSet.new(options[:schemes] || options[:write])
    end

    def [](*keys)
      __parse__(@adapter.get(*keys.collect { |key| key.to_s }))
    end

    def []=(key, value)
      @adapter.set(key.to_s, __unparse__(value))
    end

    def method_missing(name, *args)
      args.empty? ? Daijobu::NamespaceProxy.new(self, name) : Daijobu::NamespaceProxy.new(self, name)[*args]
    end

    private

    def __parse__(str)
      @read_schemes.parse(str)
    end

    def __unparse__(obj)
      @write_schemes.unparse(obj)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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