lib/brief/document.rb in brief-1.8.11 vs lib/brief/document.rb in brief-1.8.12
- old
+ new
@@ -119,9 +119,26 @@
def briefcase
(@briefcase_root && Brief.cases[@briefcase_root]) || Brief.case
end
+ def has_sections?
+ model_class.section_mappings.length > 0
+ end
+
+ def section_headings
+ sections.keys
+ end
+
+ def sections_data
+ section_headings.reduce({}) do |memo, heading|
+ section = sections.send(heading)
+ items = section.items rescue nil
+ memo[heading] = items if items
+ memo
+ end
+ end
+
def sections
mappings = model_class.section_mappings
@sections = {}.to_mash