Class: PageTreeSerializer

Inherits:
ActiveModel::Serializer
  • Object
show all
Defined in:
app/serializers/page_tree_serializer.rb

Instance Method Summary collapse

Instance Method Details

#childrenObject


19
20
21
# File 'app/serializers/page_tree_serializer.rb', line 19

def children
  object.subpages.visible.in_locale(object.locale)
end

#paramObject


23
24
25
# File 'app/serializers/page_tree_serializer.rb', line 23

def param
  object.to_param
end

#permissionsObject


27
28
29
30
# File 'app/serializers/page_tree_serializer.rb', line 27

def permissions
  [(:edit if policy.edit?),
   (:create if policy.edit?)].compact
end

#starts_atObject


10
11
12
13
14
15
16
17
# File 'app/serializers/page_tree_serializer.rb', line 10

def starts_at
  return nil unless object.starts_at?
  if object.all_day?
    I18n.l(object.starts_at.to_date, format: :long)
  else
    I18n.l(object.starts_at, format: :long)
  end
end