Class: LeanCloud::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/lean_cloud/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



12
13
14
# File 'lib/lean_cloud/client.rb', line 12

def initialize(options)
  @options = LeanCloud.config.dup.merge(options)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/lean_cloud/client.rb', line 7

def options
  @options
end

Instance Method Details

#adapterObject



16
17
18
# File 'lib/lean_cloud/client.rb', line 16

def adapter
  http_adapter
end

#headers(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/lean_cloud/client.rb', line 24

def headers(options={})
  {
    "X-AVOSCloud-Application-Id"  => app_id,
    "X-AVOSCloud-Application-Key" => app_key,
    "X-AVOSCloud-Master-Key"      => master_key,
    'Content-Type'                => 'application/json',
    'User-Agent'                  => "LeanCloud SDK Ruby / #{LeanCloud::VERSION}"
  }.merge(options)
end

#instance(options = {}, &block) ⇒ Object



20
21
22
# File 'lib/lean_cloud/client.rb', line 20

def instance(options={}, &block)
  adapter.new(url, headers: headers, &block)
end

#urlObject



34
35
36
# File 'lib/lean_cloud/client.rb', line 34

def url
  [host, version].join('/')
end