Class: Productive::Base

Inherits:
JsonApiClient::Resource
  • Object
show all
Defined in:
lib/productive/resources/base.rb

Constant Summary collapse

PER_PAGE =
1000

Class Method Summary collapse

Class Method Details

.connection_objectObject



21
22
23
# File 'lib/productive/resources/base.rb', line 21

def self.connection_object
  RequestStore.store[:json_api_client_base_connection_object]
end

.connection_object=(connection) ⇒ Object



25
26
27
# File 'lib/productive/resources/base.rb', line 25

def self.connection_object=(connection)
  RequestStore.store[:json_api_client_base_connection_object] = connection
end

.connection_optionsObject



13
14
15
# File 'lib/productive/resources/base.rb', line 13

def self.connection_options
  RequestStore.store[:json_api_client_base_connection_options]
end

.connection_options=(options) ⇒ Object



17
18
19
# File 'lib/productive/resources/base.rb', line 17

def self.connection_options=(options)
  RequestStore.store[:json_api_client_base_connection_options] = options
end

.connection_options_setup(config) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/productive/resources/base.rb', line 41

def self.connection_options_setup(config)
  if config.connection_options[:headers].nil?
    config.connection_options[:headers] = { 'X-Auth-Token' => config.api_key }
  else
    config.connection_options[:headers]['X-Auth-Token'] = config.api_key
  end

  self.connection_options = config.connection_options
end

.paginator_setup(config) ⇒ Object



51
52
53
# File 'lib/productive/resources/base.rb', line 51

def self.paginator_setup(config)
  self.paginator = config.paginator
end

.query_builder_setup(config) ⇒ Object



55
56
57
# File 'lib/productive/resources/base.rb', line 55

def self.query_builder_setup(config)
  self.query_builder = config.query_builder
end

.reset_connectionObject



59
60
61
# File 'lib/productive/resources/base.rb', line 59

def self.reset_connection
  connection(rebuild: true)
end

.setup(config) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/productive/resources/base.rb', line 29

def self.setup(config)
  site_setup config
  connection_options_setup config
  paginator_setup config
  query_builder_setup config
  reset_connection
end

.siteObject



5
6
7
# File 'lib/productive/resources/base.rb', line 5

def self.site
  RequestStore.store[:json_api_client_base_site]
end

.site=(site) ⇒ Object



9
10
11
# File 'lib/productive/resources/base.rb', line 9

def self.site=(site)
  RequestStore.store[:json_api_client_base_site] = site
end

.site_setup(config) ⇒ Object



37
38
39
# File 'lib/productive/resources/base.rb', line 37

def self.site_setup(config)
  self.site = File.join config.base_url, '/'
end