Module: CMS::Configuration
Instance Method Summary collapse
- #attributes(attributes, type) ⇒ Object
- #data ⇒ Object
- #pages ⇒ Object
- #scoped_types(options) ⇒ Object
- #types ⇒ Object
Instance Method Details
#attributes(attributes, type) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cms/configuration.rb', line 35 def attributes attributes, type attributes.map do |args| = args. name = args.shift format = args.pop || .delete('format') attribute = CMS::Attribute.new(name, format, ) attribute.reference_to.references << type if attribute.reference? attribute end end |
#data ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/cms/configuration.rb', line 4 def data @data ||= if yaml_string_data.present? YAML.load(yaml_string_data).reverse_merge(default_empty_data) else default_empty_data end end |
#pages ⇒ Object
46 47 48 49 50 |
# File 'lib/cms/configuration.rb', line 46 def pages data['pages'].map do |route, page_config| CMS::Page.new route.dup, HashWithIndifferentAccess.new(page_config) end end |
#scoped_types(options) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/cms/configuration.rb', line 12 def scoped_types if [:only] [types.find{|t| [:only] == t.name}] else types.reject{|t| [:except].include?(t.name)} end end |
#types ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cms/configuration.rb', line 20 def types if defined?(@types) then return @types end # raise data['content_types'].inspect @types = data['content_types'].map do |name, config| CMS::Type.new(name, config.delete('attributes'), config) end @types.each do |type| type.attributes = attributes(type.attributes, type) end @types end |