Sha256: 13c1cc94aa818ef52c8b6d93f4444e3936b2482d0430ce8e40c5e0591960c944

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module DiscourseSubscriptionClient
  class NoticeSerializer < ApplicationSerializer
    attributes :id,
               :title,
               :message,
               :notice_type,
               :notice_subject_type,
               :notice_subject_id,
               :plugin_status_resource,
               :created_at,
               :expired_at,
               :updated_at,
               :dismissed_at,
               :retrieved_at,
               :hidden_at,
               :dismissable,
               :can_hide

    has_one :supplier, serializer: DiscourseSubscriptionClient::SupplierSerializer, embed: :objects
    has_one :resource, serializer: DiscourseSubscriptionClient::ResourceSerializer, embed: :objects

    def include_supplier?
      object.supplier.present?
    end

    def include_resource?
      object.resource.present?
    end

    def plugin_status_resource
      object.plugin_status_resource?
    end

    def dismissable
      object.dismissable?
    end

    def can_hide
      object.can_hide?
    end

    def notice_type
      SubscriptionClientNotice.types.key(object.notice_type)
    end

    def messsage
      PrettyText.cook(object.message)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
discourse_subscription_client-0.1.11 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.10 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.9 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.8 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.7 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.6 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.5 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.4 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.3 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.2 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.1 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre15 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre14 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre13 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre12 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre11 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre10 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre9 app/serializers/discourse_subscription_client/notice_serializer.rb
discourse_subscription_client-0.1.0.pre8 app/serializers/discourse_subscription_client/notice_serializer.rb