Class: BupBupRB::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bup_bup_rb/client.rb

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
# File 'lib/bup_bup_rb/client.rb', line 17

def initialize
  @config ||= Configuration.instance

  @connection = ::Faraday.new(:url => @config.url) do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger
    faraday.adapter  Faraday.default_adapter
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/bup_bup_rb/client.rb', line 11

def config
  @config
end

#connectionObject (readonly)

Returns the value of attribute connection.



11
12
13
# File 'lib/bup_bup_rb/client.rb', line 11

def connection
  @connection
end

Class Method Details

.configure {|Configuration.instance| ... } ⇒ Object

Yields:



13
14
15
# File 'lib/bup_bup_rb/client.rb', line 13

def self.configure
  yield(Configuration.instance) if block_given?
end

.connectionObject



27
28
29
# File 'lib/bup_bup_rb/client.rb', line 27

def self.connection
  instance.connection
end

Instance Method Details

#access_tokenObject



31
32
33
# File 'lib/bup_bup_rb/client.rb', line 31

def access_token
  BupBupRB::Resource::AccessToken
end

#deviceObject



35
36
37
# File 'lib/bup_bup_rb/client.rb', line 35

def device
  BupBupRB::Resource::Device
end

#notificationObject



39
40
41
# File 'lib/bup_bup_rb/client.rb', line 39

def notification
  BupBupRB::Resource::Notification
end