Class: Jimson::Client
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Jimson::Client
- Defined in:
- lib/jimson/client.rb,
lib/jimson/client/error.rb
Defined Under Namespace
Modules: Error
Class Method Summary collapse
Instance Method Summary collapse
- #[](method, *args) ⇒ Object
-
#initialize(url, opts = {}, namespace = nil, client_opts = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(url, opts = {}, namespace = nil, client_opts = {}) ⇒ Client
Returns a new instance of Client.
172 173 174 175 |
# File 'lib/jimson/client.rb', line 172 def initialize(url, opts = {}, namespace = nil, client_opts = {}) @url, @opts, @namespace, @client_opts = url, opts, namespace, client_opts @helper = ClientHelper.new(url, opts, namespace, client_opts) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
177 178 179 180 |
# File 'lib/jimson/client.rb', line 177 def method_missing(sym, *args, &block) args = args.first if args.size == 1 && args.first.is_a?(Hash) @helper.process_call(sym, args) end |
Class Method Details
.batch(client) {|batch_client| ... } ⇒ Object
165 166 167 168 169 170 |
# File 'lib/jimson/client.rb', line 165 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
182 183 184 185 186 187 188 189 190 |
# File 'lib/jimson/client.rb', line 182 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 args = args.first if args.size == 1 && args.first.is_a?(Hash) @helper.process_call(method, args) end |