extended_description_serializer.rb 403 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. class REST::ExtendedDescriptionSerializer < ActiveModel::Serializer
  3. attributes :updated_at, :content
  4. def updated_at
  5. object.updated_at&.iso8601
  6. end
  7. def content
  8. if object.text.present?
  9. markdown.render(object.text)
  10. else
  11. ''
  12. end
  13. end
  14. private
  15. def markdown
  16. @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML)
  17. end
  18. end