Module: PageFactory::PageExtensions

Defined in:
lib/page_factory/page_extensions.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/page_factory/page_extensions.rb', line 3

def self.included(base)
  base.instance_eval do
    def default_page_parts(config=Radiant::Config)
      PageFactory.current_factory.parts
    end
    private_class_method :default_page_parts
  end
  base.class_eval do
    ##
    # The PageFactory that was used to create this page. Note that Plain
    #   Old Pages do not have an assigned factory.
    #
    # @return [PageFactory, nil] This Page's initial PageFactory
    def page_factory
      (factory = read_attribute(:page_factory)).blank? ? nil : factory.constantize
    rescue NameError => e # @page.page_factory is not a constant. class was removed?
      logger.warn "Couldn't find page factory: #{e.message}"
      nil
    end
  end
end