Class: Hyrax::Analytics::Config

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/analytics.rb

Constant Summary collapse

REQUIRED_KEYS =
%w[app_name app_version privkey_path privkey_secret client_email].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Config

Returns a new instance of Config.



32
33
34
# File 'app/services/hyrax/analytics.rb', line 32

def initialize(config)
  @config = config
end

Class Method Details

.load_from_yamlObject



20
21
22
23
24
25
26
27
28
# File 'app/services/hyrax/analytics.rb', line 20

def self.load_from_yaml
  filename = Rails.root.join('config', 'analytics.yml')
  yaml = YAML.safe_load(File.read(filename))
  unless yaml
    Rails.logger.error("Unable to fetch any keys from #{filename}.")
    return new({})
  end
  new yaml.fetch('analytics')
end

Instance Method Details

#valid?Boolean

Returns are all the required values present?.

Returns:

  • (Boolean)

    are all the required values present?



37
38
39
40
# File 'app/services/hyrax/analytics.rb', line 37

def valid?
  config_keys = @config.keys
  REQUIRED_KEYS.all? { |required| config_keys.include?(required) }
end