Class: PhraseApp::InContextEditor::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/phraseapp-in-context-editor-ruby/config.rb

Constant Summary collapse

CONFIG_OPTIONS =
{
  project_id: nil,
  access_token: nil,
  enabled: false,
  skip_ssl_verification: false,
  backend: PhraseApp::InContextEditor::BackendService.new,
  prefix: "{{__",
  suffix: "__}}",
  api_host: "https://api.phraseapp.com",
  js_host: "phraseapp.com",
  js_use_ssl: true,
  js_path: "/assets/in-context-editor/2.0/app.js",
  js_options: {},
  cache_key_segments_initial: ["simple_form"],
  cache_lifetime: 300,
  ignored_keys: [],
}.freeze
CONFIG_OPTIONS_GLOBAL_ONLY =
[
  :access_token,
  :skip_ssl_verification,
  :api_host
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.api_clientObject



49
50
51
# File 'lib/phraseapp-in-context-editor-ruby/config.rb', line 49

def self.api_client
  @@api_client ||= build_api_client
end

.reset_to_defaults!Object



63
64
65
66
67
# File 'lib/phraseapp-in-context-editor-ruby/config.rb', line 63

def self.reset_to_defaults!
  CONFIG_OPTIONS.each do |option, default_value|
    send("#{option}=", default_value)
  end
end

Instance Method Details

#api_clientObject



53
54
55
# File 'lib/phraseapp-in-context-editor-ruby/config.rb', line 53

def api_client
  self.class.api_client
end

#assign_values(config_options = {}) ⇒ Object



57
58
59
60
61
# File 'lib/phraseapp-in-context-editor-ruby/config.rb', line 57

def assign_values(config_options={})
  config_options.each do |config_option, value|
    self.send("#{config_option}=", value)
  end
end