Sha256: f166bb0a781510959b68176b3cff202bbe33fb341ea8d7c2a0261d5c424acd7f

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 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,
        cache_enabled:      true,
        fullpath:           {},
        response_type:      nil,
        content_type:       nil,
        target_klass_name:  nil,
        position:           99,
        raw_template:       nil,
        source:             nil,
        editable_elements:  {},
        redirect:           false,
        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 redirect?; redirect.nil? ? redirect_url.present? : redirect; 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 depth
      @depth || self[:depth]
    end

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

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/entities/page.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/entities/page.rb