Class: Baron::Theme

Inherits:
Hash
  • Object
show all
Defined in:
lib/baron/models/theme.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Theme

Returns a new instance of Theme.



5
6
7
8
9
10
11
# File 'lib/baron/models/theme.rb', line 5

def initialize config
  @config = config
  self[:root] = "/themes/#{config[:theme]}"
  self[:name] = config[:theme]
  self[:file_root] = "#{@config[:sample_data_path]}themes/#{@config[:theme]}".squeeze('/')
  self[:theme_config] = "#{self[:file_root]}/theme_config.yml".squeeze('/')
end

Instance Method Details

#get_template(name) ⇒ Object



25
26
27
# File 'lib/baron/models/theme.rb', line 25

def get_template name
  "#{self[:file_root]}/templates/#{name}.rhtml".squeeze('/')
end

#load_config(filename_and_path = '') ⇒ Object



13
14
15
16
17
18
19
# File 'lib/baron/models/theme.rb', line 13

def load_config filename_and_path = ''
  filename_and_path = filename_and_path.empty? ? self[:theme_config] : filename_and_path
  params = YAML.load(File.read(filename_and_path))
  params.each_pair { |key, value| self[key.downcase.to_sym] = value } unless !params
rescue Errno::ENOENT => e
  # puts "Warning: unable to load config file : " + filename_and_path
end

#rootObject



21
22
23
# File 'lib/baron/models/theme.rb', line 21

def root
   self[:root]
end