Sha256: 1ae7c78fdc8bf5320f5432afceb1e53f71760b442d42ff2b24c4e3f1821555d4

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

module Munson
  class Client
    extend Forwardable
    def_delegators :query, :include, :sort, :filter, :fields, :fetch, :page, :find
    def_delegators :connection, :url=, :url, :response_key_format, :response_key_format=

    attr_writer :path
    attr_writer :query_builder
    attr_accessor :type

    def initialize(opts={})
      opts.each do |k,v|
        setter = "#{k}="
        send(setter,v) if respond_to?(setter)
      end
    end

    def query
      (@query_builder || Query).new(self)
    end

    def agent
      Agent.new(path, connection: connection)
    end

    def path
      @path || "/#{type}"
    end

    def configure(&block)
      yield(self)
      self
    end

    def connection
      @connection ||= Munson.default_connection.clone
    end

    def connection=(connection)
      @connection = connection
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
munson-0.3.0 lib/munson/client.rb