Class: FormatForExtensions::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/format_for_extensions/config.rb

Constant Summary collapse

DEFAULT_LOCALE =

TODO: Bake in support for multiple locales…

'en'

Class Method Summary collapse

Class Method Details

.fieldsObject

Returns the configured fields



25
26
27
# File 'lib/format_for_extensions/config.rb', line 25

def self.fields
  values.keys
end

.propertiesObject

returns the configured properties (of the first field)



30
31
32
# File 'lib/format_for_extensions/config.rb', line 30

def self.properties
  values[fields.first].keys
end

.values(locale = DEFAULT_LOCALE) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/format_for_extensions/config.rb', line 8

def self.values(locale = DEFAULT_LOCALE)
  @@config ||= nil
  
  # First, we want to see if the consumer of this gem has defined a config file
  return @@config[locale] unless @@config.nil?
  
  begin
    @@config = YAML.load_file(File.join(Rails.root, 'config', 'format_for_extensions.yml'))
  rescue
    # fall back to our smart defaults
    @@config = YAML.load_file(File.join(File.dirname(__FILE__), '../../config', 'format_for_extensions.yml'))
  end
  
  @@config[locale]
end