Class: ActivityPub::BaseSerializer
- Inherits:
-
Granola::Serializer
- Object
- Granola::Serializer
- ActivityPub::BaseSerializer
- Includes:
- RoutingHelper
- Defined in:
- app/serializers/activitypub/base_serializer.rb
Direct Known Subclasses
AcceptFollowSerializer, ActivitySerializer, ActorSerializer, CommentSerializer, FollowSerializer, ImageSerializer, LikeSerializer, OutboxSerializer, StorySerializer, StorySerializer::TagSerializer, UndoLikeSerializer, UpdateSerializer
Constant Summary collapse
- CONTEXT =
[ 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', { 'Hashtag' => 'as:Hashtag' }, { 'votes' => { '@id' => 'as:votes', '@type' => '@id' } } ].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #as_json(opts = {}) ⇒ Object
-
#initialize(object, options = {}) ⇒ BaseSerializer
constructor
A new instance of BaseSerializer.
- #to_json(opts = {}) ⇒ Object
Constructor Details
#initialize(object, options = {}) ⇒ BaseSerializer
Returns a new instance of BaseSerializer.
21 22 23 24 |
# File 'app/serializers/activitypub/base_serializer.rb', line 21 def initialize(object, = {}) @options = super(object) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'app/serializers/activitypub/base_serializer.rb', line 19 def @options end |
Instance Method Details
#as_json(opts = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/serializers/activitypub/base_serializer.rb', line 26 def as_json(opts = {}) .merge!(opts) json = data json['@context'] = CONTEXT if [:with_context] json end |
#to_json(opts = {}) ⇒ Object
35 36 37 |
# File 'app/serializers/activitypub/base_serializer.rb', line 35 def to_json(opts = {}) Oj.dump(as_json(opts)) end |