Sha256: 9e392ed34dd21171db93ed4ed237faa812aea0c6cd916802fbb23c62484d20e3

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module FeatherCms
  class Config
    class << self
      attr_accessor :cache_max_limit, :cache_permanent_keys
      attr_accessor :template_store_type

      @@config = {
        :template_store_path => 'templates',
        :use_version => true,
        :template_extenstion => 'html'
      }

      def init(&block)
        yield self if block_given? 

        template_store_type = (template_store_type || :file).to_sym
        FeatherCms::TemplateCache.init
        Dir.mkdir(template_store_path) unless Dir.exists?(template_store_path)

        if defined?(ActionView::Helpers)
          ActionView::Helpers.send(:include, FeatherCms::ViewHelper)
        end

        if defined?(Rails)
          @@config[:layouts] = Dir.entries(Rails.root.to_s + '/app/views/layouts').reject do |i|
            i.start_with?('.', '_', 'feather_layout')
          end.collect{|l| l.split('.').first}
        end
      end

      def layouts
        @@config[:layouts]
      end

      [:template_store_path, :template_extenstion, :authentication].each do |attr|
        class_eval <<-METHOD, __FILE__, __LINE__ + 1
          def #{attr}=(value)
            @@config[:#{attr}] = value
          end

          def #{attr}
            @@config[:#{attr}]
          end
        METHOD
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feather_cms-0.0.3 lib/feather_cms/config.rb