Class: Tenon::ApplicationSerializer

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

Overview

Some basic functionality that most resources will want

Direct Known Subclasses

ItemVersionSerializer, AssetSerializer

Instance Method Summary collapse

Instance Method Details

#attributesObject



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

def attributes
  super.merge(default_attributes)
end

#formatted_publish_atObject



4
5
6
7
8
# File 'app/serializers/tenon/application_serializer.rb', line 4

def formatted_publish_at
  if object.publish_at.present?
    object.publish_at.strftime('%B %e, %Y at %-l:%m%p')
  end
end

#resource_typeObject



14
15
16
17
# File 'app/serializers/tenon/application_serializer.rb', line 14

def resource_type
  klass = object.object ? object.object.class : object.class
  klass.to_s.underscore
end

#to_paramObject



10
11
12
# File 'app/serializers/tenon/application_serializer.rb', line 10

def to_param
  object.to_param
end