Sha256: 8840837ef5af2cee036ce8d9dca6fbb31cea269398550eb7ab1f0887a435c01a

Contents?: true

Size: 913 Bytes

Versions: 5

Compression:

Stored size: 913 Bytes

Contents

require 'active_record/associations'
require 'dispatcher'

module Cms
  autoload :Context, 'liquid_cms/context'
  autoload :ContextAssociation, 'liquid_cms/context_association'
  autoload :Association, 'association'

  mattr_reader :context_class
  def self.context_class=(klass)
    @@context_class = klass
    return if klass.nil? || ENV['NO_CONTEXT'] == 'true'

    Dispatcher.to_prepare {
      eval(klass.to_s).extend Cms::ContextAssociation

      Cms::Page.belongs_to  :context, :class_name => klass.to_s
      Cms::Asset.belongs_to :context, :class_name => klass.to_s
    }
  end
  @@context_class = nil

  def self.set_context(context, bind_to)
    return if @@context_class.nil?
    bind_to.instance_variable_set :@cms_context, context
  end

  def self.global_route(route_map)
    route_map.connect '*url', :controller => 'cms/pages', :action => 'load'
  end

  def self.setup
    yield self
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
liquid_cms-0.2.0.13 lib/liquid_cms/configuration.rb
liquid_cms-0.2.0.12 lib/liquid_cms/configuration.rb
liquid_cms-0.2.0.11 lib/liquid_cms/configuration.rb
liquid_cms-0.2.0.10 lib/liquid_cms/configuration.rb
liquid_cms-0.2.0.4 lib/liquid_cms/configuration.rb