Class: Googlets::Googlet

Inherits:
Object
  • Object
show all
Defined in:
lib/googlets/googlet.rb

Direct Known Subclasses

Analytics, Libraries

Class Method Summary collapse

Class Method Details

.config_fileObject



19
20
21
# File 'lib/googlets/googlet.rb', line 19

def self.config_file
  Rails.root.join('config', 'google.yml')
end

.enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/googlets/googlet.rb', line 23

def self.enabled?
  true
end

.parse_configObject



5
6
7
8
9
# File 'lib/googlets/googlet.rb', line 5

def self.parse_config
  read_config.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

.read_configObject



11
12
13
14
15
16
17
# File 'lib/googlets/googlet.rb', line 11

def self.read_config
  return {} unless File.exist?(config_file)

  config = YAML::load(ERB.new(IO.read(config_file)).result)[Rails.env] || {}
  config.symbolize_keys!
  config
end