Class: TypeStation::Page

Inherits:
Entity
  • Object
show all
Includes:
Concerns::PathGenerator, Concerns::Templatable
Defined in:
app/models/type_station/page.rb

Constant Summary collapse

STATUS =
[:hidden, :draft, :published]

Instance Method Summary collapse

Methods included from Concerns::Templatable

#template_name?

Methods inherited from Entity

#content?, #content_attributes, #entity_fields?, find_by_name, #get, #move_entity, #set, #update_contents

Instance Method Details

#redirect?Boolean

INSTANT METHODS

Returns:

  • (Boolean)


19
20
21
# File 'app/models/type_station/page.rb', line 19

def redirect?
  redirect_to.present?
end

#visible?(user) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'app/models/type_station/page.rb', line 23

def visible?(user)
  return true if parent_id == nil # The root page is always visible

  if user.present?
    [:draft, :published].include?(status)
  else
    status == :published
  end
end