Class: Jimson::Client

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/jimson/client.rb,
lib/jimson/client/error.rb

Defined Under Namespace

Modules: Error

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}, namespace = nil) ⇒ Client

Returns a new instance of Client.



159
160
161
162
# File 'lib/jimson/client.rb', line 159

def initialize(url, opts = {}, namespace = nil)
  @url, @opts, @namespace = url, opts, namespace
  @helper = ClientHelper.new(url, opts, namespace)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



164
165
166
# File 'lib/jimson/client.rb', line 164

def method_missing(sym, *args, &block)
  @helper.process_call(sym, args) 
end

Class Method Details

.batch(client) {|batch_client| ... } ⇒ Object

Yields:

  • (batch_client)


152
153
154
155
156
157
# File 'lib/jimson/client.rb', line 152

def self.batch(client)
  helper = client.instance_variable_get(:@helper)
  batch_client = BatchClient.new(helper)
  yield batch_client
  helper.send_batch
end

Instance Method Details

#[](method, *args) ⇒ Object



168
169
170
171
172
173
174
175
# File 'lib/jimson/client.rb', line 168

def [](method, *args)
  if method.is_a?(Symbol)
    # namespace requested
    new_ns = @namespace.nil? ? "#{method}." : "#@namespace#{method}."
    return Client.new(@url, @opts, new_ns)
  end
  @helper.process_call(method, args) 
end