Sha256: 5bb85fb1ad25096dd00db97b727ed778bb9725273dd20d8d68840c0ed5df879c

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

module Rapporteur
  # An ActiveModel::Serializer used to serialize the checker data for JSON
  # rendering.
  #
  class Serializer < ActiveModel::Serializer
    self.root = false

    attributes :revision,
               :time,
               :messages

    # Internal: Converts the checker instance time into UTC to provide a
    # consistent public representation.
    #
    # Returns a Time instance in UTC.
    #
    def time
      object.time.utc
    end

    # Internal: Used by ActiveModel::Serializer to determine whether or not to
    # include the messages attribute.
    #
    # Returns false if the messages are empty.
    #
    def include_messages?
      !object.messages.empty?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rapporteur-1.1.0 lib/rapporteur/serializer.rb