Module: Sedative

Defined in:
lib/sedative.rb,
lib/sedative/version.rb,
lib/generators/sedative/install/install_generator.rb

Defined Under Namespace

Modules: Generators

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.hash(file_name) ⇒ Object



20
21
22
# File 'lib/sedative.rb', line 20

def self.hash(file_name)
  Hashie::Mash.new YAML.load_file("#{Rails.root}/config/settings/#{file_name}.yml")[Rails.env]
end

.initializeObject



6
7
8
9
10
# File 'lib/sedative.rb', line 6

def self.initialize
  setting_names.each do |name|
    Object.const_set pretty_name(name), hash(name)
  end
end

.pretty_name(name) ⇒ Object



24
25
26
# File 'lib/sedative.rb', line 24

def self.pretty_name(name)
  name.split("_").map(&:capitalize).join.gsub(" ", "")
end

.setting_namesObject



12
13
14
15
16
17
18
# File 'lib/sedative.rb', line 12

def self.setting_names
  settings = []
  Dir.glob("config/settings/*.yml").each do |file|
    settings << File.basename(file, ".yml")
  end
  settings
end