Class: RailsConnector::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_connector/configuration.rb

Constant Summary collapse

DEFAULT_CA_FILE =

Default path of a CA certification file in PEM format.

File.expand_path('../../../config/ca-bundle.crt', __FILE__)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.ca_fileObject

Gets path of a CA certification file in PEM format.



54
55
56
# File 'lib/rails_connector/configuration.rb', line 54

def ca_file
  @ca_file
end

Class Method Details

.cache_path=(path) ⇒ Object

The RailsConnector makes heavy use of filesystem caching. Use this method to configure the directory that should be used to store cached data. By default, RAILS_ROOT/tmp/infopark_cache will be used.

Examples:

Configure RailsConnector to store its cache under /tmp/my_cache.

RailsConnector::Configuration.cache_path = '/tmp/my_cache'

Parameters:

  • path (String)

    Path to directory that should be used to store cached data.



48
49
50
# File 'lib/rails_connector/configuration.rb', line 48

def cache_path=(path)
  CmsCacheStorage.backend_cache = ActiveSupport::Cache::FileStore.new(path)
end

.choose_homepage(&block) ⇒ Object

Configure a callback to be invoked when the rails connector delivers the homepage. The given callback will receive the rack env and must return an Obj to be used as the homepage. If no callback is configured, Obj.homepage will be used as the default.



157
158
159
# File 'lib/rails_connector/configuration.rb', line 157

def choose_homepage(&block)
  self.choose_homepage_callback = block
end

.cms_api_keyObject

API key configuration for CMS Rest API.



128
129
130
# File 'lib/rails_connector/configuration.rb', line 128

def cms_api_key
  cms_api.api_key
end

.cms_api_key=(value) ⇒ Object

Set API key configuration for CMS Rest API.



134
135
136
# File 'lib/rails_connector/configuration.rb', line 134

def cms_api_key=(value)
  cms_api.api_key = value
end

.cms_loginObject

Login configuration for CMS Rest API.



116
117
118
# File 'lib/rails_connector/configuration.rb', line 116

def 
  cms_api.
end

.cms_login=(value) ⇒ Object

Set login configuration for CMS Rest API.



122
123
124
# File 'lib/rails_connector/configuration.rb', line 122

def cms_login=(value)
  cms_api. = value
end

.cms_urlObject

Url configuration for CMS Rest API.



104
105
106
# File 'lib/rails_connector/configuration.rb', line 104

def cms_url
  cms_api.url
end

.cms_url=(value) ⇒ Object

Set url configuration for CMS Rest API.



110
111
112
# File 'lib/rails_connector/configuration.rb', line 110

def cms_url=(value)
  cms_api.url = value
end

.content_service_api_keyObject

Configuration for Content Read Service API.



92
93
94
# File 'lib/rails_connector/configuration.rb', line 92

def content_service_api_key
  content_service.api_key
end

.content_service_api_key=(value) ⇒ Object

Set API key configuration for Content Read Service API.



98
99
100
# File 'lib/rails_connector/configuration.rb', line 98

def content_service_api_key=(value)
  content_service.api_key = value
end

.content_service_loginObject

Configuration for Content Read Service API.



80
81
82
# File 'lib/rails_connector/configuration.rb', line 80

def 
  content_service.
end

.content_service_login=(value) ⇒ Object

Set login configuration for Content Read Service API.



86
87
88
# File 'lib/rails_connector/configuration.rb', line 86

def content_service_login=(value)
  content_service. = value
end

.content_service_urlObject

Configuration for Content Read Service API.



68
69
70
# File 'lib/rails_connector/configuration.rb', line 68

def content_service_url
  content_service.url
end

.content_service_url=(value) ⇒ Object

Set url configuration for Content Read Service API.



74
75
76
# File 'lib/rails_connector/configuration.rb', line 74

def content_service_url=(value)
  content_service.url = value
end

.editing_auth(&block) ⇒ Object

Configure a callback to be invoked when the rails connector determines, if current visitor is permitted to edit content. Default is false.

Example Usage:

RailsConnector::Configuation.editing_auth do |env|
  request = Rack::Request.new(env)
  # return truey if current visitor is permitted to edit content, falsy otherwise
end


28
29
30
31
32
33
34
# File 'lib/rails_connector/configuration.rb', line 28

def editing_auth(&block)
  if block.respond_to?(:arity) && block.arity == 1
    self.editing_auth_callback = block
  else
    raise ArgumentError, 'editing_auth should have only one attribute!'
  end
end