Sha256: 44cdc41085c01eaf2fca9acccf56bdd71986e9aaea3e2619d16b4d6821e729bf

Contents?: true

Size: 835 Bytes

Versions: 2

Compression:

Stored size: 835 Bytes

Contents

module PageFactory
  module PageExtensions
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-page_factory-extension-1.0.1 lib/page_factory/page_extensions.rb
radiant-page_factory-extension-1.0.0 lib/page_factory/page_extensions.rb