Class: Lcms::Engine::ResourceInstructionSerializer
- Inherits:
-
ActiveModel::Serializer
- Object
- ActiveModel::Serializer
- Lcms::Engine::ResourceInstructionSerializer
show all
- Includes:
- ResourceHelper
- Defined in:
- app/serializers/lcms/engine/resource_instruction_serializer.rb
Instance Method Summary
collapse
#back_to_resource_path, #copyrights_text, #download_per_category_limit, #prerequisites_standards, #resource_breadcrumbs_with_links, #show_resource_path, #type_name
Instance Method Details
#grade_avg ⇒ Object
38
39
40
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 38
def grade_avg
object.grades.average
end
|
#img ⇒ Object
30
31
32
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 30
def img
object.try(:image_file).try(:url) || placeholder
end
|
#instruction_type ⇒ Object
34
35
36
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 34
def instruction_type
media? ? object.resource_type : :generic
end
|
#path ⇒ Object
26
27
28
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 26
def path
media? ? media_path(object.id) : generic_path(object)
end
|
#subject ⇒ Object
18
19
20
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 18
def subject
object.subject.try(:downcase) || 'default'
end
|
#teaser ⇒ Object
22
23
24
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 22
def teaser
object.title
end
|
#title ⇒ Object
11
12
13
14
15
16
|
# File 'app/serializers/lcms/engine/resource_instruction_serializer.rb', line 11
def title
return object.title if media?
type_name = I18n.t("resource_types.#{object.resource_type}")
object.grades.present? ? "#{object.grades.to_str} #{type_name}" : type_name
end
|