Class: Layout
- Inherits:
-
Object
- Object
- Layout
- Defined in:
- app/models/layout.rb
Class Method Summary collapse
Instance Method Summary collapse
- #containers ⇒ Object
-
#initialize(name) ⇒ Layout
constructor
A new instance of Layout.
- #path ⇒ Object
Constructor Details
#initialize(name) ⇒ Layout
Returns a new instance of Layout.
24 25 26 |
# File 'app/models/layout.rb', line 24 def initialize(name) @name = name end |
Class Method Details
.all ⇒ Object
2 3 4 5 6 7 |
# File 'app/models/layout.rb', line 2 def self.all files.map do |layout| layout = layout.split('/').last.gsub(file_extension, '') [layout.titleize, layout] end end |
.file_extension ⇒ Object
20 21 22 |
# File 'app/models/layout.rb', line 20 def self.file_extension '.html.erb' end |
.files ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/layout.rb', line 9 def self.files files = [] SlicesController.view_paths.each do |resolver| query = File.join(resolver, 'layouts', "*#{file_extension}") files.concat(Dir.glob(query)) end files.reject do |file| file.include?('admin.html.erb') end.uniq.sort end |
Instance Method Details
#containers ⇒ Object
34 35 36 37 |
# File 'app/models/layout.rb', line 34 def containers parser = Slices::ContainerParser.new(path) parser.parse end |
#path ⇒ Object
28 29 30 31 32 |
# File 'app/models/layout.rb', line 28 def path self.class.files.select do |path| path.split('/').last == @name + self.class.file_extension end.first end |