ref: master
app/models/layout_template.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
class LayoutTemplate def self.find(id) t = new(id) t.send(:read_config) t end def self.all Dir.glob(Rails.root.join('public', 'designs', 'templates', '*')).map {|item| find(File.basename(item)) } end attr_reader :id def initialize(id) @id = id end def name _ @config['name'] end def title _ @config['title'] end def description _ @config['description'] end def number_of_boxes @config['number_of_boxes'] end protected def read_config @config = YAML.load_file(Rails.root.join('public', 'designs', 'templates', id, 'config.yml')) end end |