Class: Locomotive::Steam::Page

Inherits:
Object
  • Object
show all
Includes:
Models::Entity
Defined in:
lib/locomotive/steam/entities/page.rb

Instance Attribute Summary collapse

Attributes included from Models::Entity

#associations, #attributes, #base_url, #localized_attributes

Instance Method Summary collapse

Methods included from Models::Entity

#[], #[]=, #_id, #change, #method_missing, #respond_to?, #serialize

Methods included from Models::Concerns::ToJson

#as_json, #to_hash, #to_json

Methods included from Models::Concerns::Validation

#errors, #valid?

Constructor Details

#initialize(attributes) ⇒ Page

Returns a new instance of Page.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/locomotive/steam/entities/page.rb', line 9

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:          {},
    sections_content:           {},
    sections_dropzone_content:  [],
    redirect:                   nil,
    redirect_url:               {},
    redirect_type:              nil,
    parent_id:                  nil,
    parent_ids:                 nil,
    updated_at:                 Time.zone.now
  }.merge(attributes))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Locomotive::Steam::Models::Entity

Instance Attribute Details

#_fullpathObject

Returns the value of attribute _fullpath.



7
8
9
# File 'lib/locomotive/steam/entities/page.rb', line 7

def _fullpath
  @_fullpath
end

#content_entryObject

Returns the value of attribute content_entry.



7
8
9
# File 'lib/locomotive/steam/entities/page.rb', line 7

def content_entry
  @content_entry
end

#depthObject

Returns the value of attribute depth.



7
8
9
# File 'lib/locomotive/steam/entities/page.rb', line 7

def depth
  @depth
end

Instance Method Details

#content_type_idObject



40
41
42
43
# File 'lib/locomotive/steam/entities/page.rb', line 40

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

#index?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/locomotive/steam/entities/page.rb', line 45

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

#layout?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/locomotive/steam/entities/page.rb', line 53

def layout?
  (attributes[:fullpath].values.first =~ Locomotive::Steam::IsLAYOUT) == 0
end

#listed?Boolean

Returns:

  • (Boolean)


35
# File 'lib/locomotive/steam/entities/page.rb', line 35

def listed?; !!listed; end

#not_found?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/locomotive/steam/entities/page.rb', line 49

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

#published?Boolean

Returns:

  • (Boolean)


36
# File 'lib/locomotive/steam/entities/page.rb', line 36

def published?; !!published; end

#redirect?Boolean

Returns:

  • (Boolean)


38
# File 'lib/locomotive/steam/entities/page.rb', line 38

def redirect?; redirect.nil? ? !redirect_url.blank? : redirect; end

#sourceObject



57
58
59
# File 'lib/locomotive/steam/entities/page.rb', line 57

def source
  self[:raw_template]
end

#templatized?Boolean

Returns:

  • (Boolean)


37
# File 'lib/locomotive/steam/entities/page.rb', line 37

def templatized?; !!templatized; end

#to_liquidObject



65
66
67
# File 'lib/locomotive/steam/entities/page.rb', line 65

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