Sha256: 7f6f5cc74d10e7dd29577efd2f3adc01968ec27e5fc5d9ac74ea4a4c9b9b1198
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
module CMS::Configuration extend self def data @data ||= YAML.load(load_yaml_string_data) end def scoped_types options if options[:only] [types.find{|t| options[:only] == t.name}] else types.reject{|t| options[:except].include?(t.name)} end end def types if defined?(@types) then return @types end @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 def attributes attributes, type attributes.map do |args| options = args.extract_options! name = args.shift format = args.pop || options.delete('format') attribute = CMS::Attribute.new(name, format, options) attribute.reference_to.references << type if attribute.reference? attribute end end def pages data['pages'].map do |route, page_config| CMS::Page.new route.dup, HashWithIndifferentAccess.new(page_config) end end private def load_yaml_string_data File.read(Rails.root.join 'config/cms.yml') end end
Version data entries
7 entries across 7 versions & 1 rubygems