Class: OmnitureRails3::Config
- Inherits:
-
Object
- Object
- OmnitureRails3::Config
- Includes:
- Singleton
- Defined in:
- lib/omniture_rails3/config.rb
Constant Summary collapse
- OPTIONS =
%w{higml_directory prop_map tracking_account visitor_namespace noscript_img_src}
Instance Method Summary collapse
- #higml_directory ⇒ Object
- #set(config) ⇒ Object
- #set_with_hash(config) ⇒ Object
- #set_with_io(config) ⇒ Object
-
#set_with_string(config) ⇒ Object
String should be either a filename or YAML.
- #set_with_yaml(config) ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#higml_directory ⇒ Object
7 8 9 |
# File 'lib/omniture_rails3/config.rb', line 7 def higml_directory @higml_directory ||= File.join(Rails.root, "app", "omniture") end |
#set(config) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/omniture_rails3/config.rb', line 11 def set(config) case config when Hash then set_with_hash(config) when IO then set_with_io(config) when String then set_with_string(config) end Higml.config.set({"higml_directory" => self.higml_directory}) end |
#set_with_hash(config) ⇒ Object
21 22 23 24 25 |
# File 'lib/omniture_rails3/config.rb', line 21 def set_with_hash(config) OPTIONS.each do |option| self.send("#{option}=", config[option]) if config[option] end end |
#set_with_io(config) ⇒ Object
36 37 38 39 |
# File 'lib/omniture_rails3/config.rb', line 36 def set_with_io(config) set_with_yaml(config) config.close end |
#set_with_string(config) ⇒ Object
String should be either a filename or YAML
28 29 30 31 32 33 34 |
# File 'lib/omniture_rails3/config.rb', line 28 def set_with_string(config) if File.exists?(config) set_with_yaml(File.read(config)) else set_with_yaml(config) end end |
#set_with_yaml(config) ⇒ Object
41 42 43 |
# File 'lib/omniture_rails3/config.rb', line 41 def set_with_yaml(config) set_with_hash(YAML.load(config)[Rails.env]) end |
#to_hash ⇒ Object
45 46 47 48 49 50 |
# File 'lib/omniture_rails3/config.rb', line 45 def to_hash OPTIONS.inject({}){ |hash, option| hash[option] = self.send(option) hash } end |