Class: Sr::Jimson::Client
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Sr::Jimson::Client
- Defined in:
- lib/sr/jimson/client.rb,
lib/sr/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
constructor
A new instance of Client.
- #method_missing(sym, *args, &block) ⇒ Object
Methods inherited from BlankSlate
find_hidden_method, hide, reveal
Constructor Details
#initialize(url, opts = {}, namespace = nil) ⇒ Client
Returns a new instance of Client.
159 160 161 162 |
# File 'lib/sr/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/sr/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
152 153 154 155 156 157 |
# File 'lib/sr/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/sr/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 |