Sha256: 55315d45f18eddf2193a8da0c5a7c329c34f0de0df7cf5e841056759e2b3fc1b

Contents?: true

Size: 948 Bytes

Versions: 3

Compression:

Stored size: 948 Bytes

Contents

module CMS::Configuration
  def data
    @data = YAML.load(File.read(Rails.root.join 'config/cms.yml'))
  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

  extend self
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
honey-cms-0.1.2 lib/cms/configuration.rb
honey-cms-0.1.1 lib/cms/configuration.rb
honey-cms-0.1.0 lib/cms/configuration.rb