Class: MassdebatorApi::Service

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/massdebator_api/service.rb

Direct Known Subclasses

Debate

Class Method Summary collapse

Class Method Details

.base_pathObject



5
6
7
# File 'lib/massdebator_api/service.rb', line 5

def self.base_path
  "/api/v1"
end

.base_uriObject



9
10
11
# File 'lib/massdebator_api/service.rb', line 9

def self.base_uri
  "http://#{self.host}#{self.base_path}"
end

.configuration_hashObject



13
14
15
16
17
18
19
# File 'lib/massdebator_api/service.rb', line 13

def self.configuration_hash
  if Rails.root
    @@config_hash ||= YAML.load_file("#{Rails.root}/config/massdebator.yml")
  else
    @@config_hash ||= YAML.load_file("config/massdebator.yml")
  end
end

.headersObject

If headers are not defined in a given subclass, then obtain headers from the superclass.



45
46
47
48
49
50
51
# File 'lib/massdebator_api/service.rb', line 45

def headers
  if defined?(@headers)
    @headers
  elsif superclass != Object && superclass.headers
    superclass.headers
  end
end

.hostObject



21
22
23
# File 'lib/massdebator_api/service.rb', line 21

def self.host
  self.configuration_hash[Rails.env]['host']
end

.portObject



33
34
35
# File 'lib/massdebator_api/service.rb', line 33

def self.port
  self.configuration_hash[Rails.env]['port']
end

.secretObject



29
30
31
# File 'lib/massdebator_api/service.rb', line 29

def self.secret
  self.configuration_hash[Rails.env]['secret']
end

.tokenObject



25
26
27
# File 'lib/massdebator_api/service.rb', line 25

def self.token
  self.configuration_hash[Rails.env]['token']
end