Sha256: 0ed9f9744d2c8b6b95e6c64c661ed84bc0f74fb895cab49a44d461c591323ce3

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

module Locomotive::Steam

  class Page

    include Locomotive::Steam::Models::Entity

    attr_accessor :depth, :_fullpath, :content_entry

    def initialize(attributes)
      super({
        handle:             nil,
        listed:             false,
        published:          true,
        templatized:        false,
        fullpath:           {},
        content_type:       nil,
        target_klass_name:  nil,
        position:           99,
        raw_template:       nil,
        source:             nil,
        editable_elements:  {},
        redirect_url:       {},
        redirect_type:      nil,
        parent_id:          nil,
        parent_ids:         nil,
        updated_at:         Time.zone.now
      }.merge(attributes))
    end

    def listed?; !!listed; end
    def published?; !!published; end
    def templatized?; !!templatized; end

    def content_type_id
      self.target_klass_name =~ Locomotive::Steam::CONTENT_ENTRY_ENGINE_CLASS_NAME
      $1 || self.target_klass_name
    end

    def index?
      attributes[:fullpath].values.first == 'index'
    end

    def not_found?
      attributes[:fullpath].values.first == '404'
    end

    def source
      self[:raw_template]
    end

    def to_liquid
      Locomotive::Steam::Liquid::Drops::Page.new(self)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/entities/page.rb