Class: DistributedPress::V1::Social::ReferencedObject
- Inherits:
-
Object
- Object
- DistributedPress::V1::Social::ReferencedObject
- Extended by:
- Forwardable
- Defined in:
- lib/distributed_press/v1/social/referenced_object.rb
Overview
Merge with Reference
An object with external references
Direct Known Subclasses
Constant Summary collapse
- PUBLIC =
Public addressing doesn’t lead to an activity
'https://www.w3.org/ns/activitystreams#Public'
- URI_FIXES =
Mastodon hides self-replies
%r{&?only_other_accounts=true&?}
- REFERENTIABLE_ATTRIBUTES =
%w[ actor owner attributedTo cc inReplyTo object replies likes shares to publicKey audience alsoKnownAs devices featured featuredTags followers following inbox movedTo outbox first items next orderedItems partOf prev ].freeze
Instance Attribute Summary collapse
-
#dereferencer ⇒ Object
readonly
Returns the value of attribute dereferencer.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#referenced ⇒ Object
readonly
Returns the value of attribute referenced.
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(_) ⇒ Object
-
#initialize(object:, dereferencer:, referenced: nil) ⇒ ReferencedObject
constructor
A new instance of ReferencedObject.
- #parsed_response ⇒ Object
-
#private? ⇒ Bool
It’s not publicly available.
-
#public? ⇒ Bool
Is this a public post? A post is public when it’s addressed to the public or doesn’t have a recipient (like Like).
- #success? ⇒ Boolean
-
#unlisted? ⇒ Bool
Is it unlisted?.
Constructor Details
#initialize(object:, dereferencer:, referenced: nil) ⇒ ReferencedObject
Returns a new instance of ReferencedObject.
58 59 60 61 62 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 58 def initialize(object:, dereferencer:, referenced: nil) @object = object @dereferencer = dereferencer @referenced = referenced || reference_object(object) end |
Instance Attribute Details
#dereferencer ⇒ Object (readonly)
Returns the value of attribute dereferencer.
53 54 55 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 53 def dereferencer @dereferencer end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
52 53 54 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 52 def object @object end |
#referenced ⇒ Object (readonly)
Returns the value of attribute referenced.
54 55 56 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 54 def referenced @referenced end |
Class Method Details
._load(array) ⇒ Object
92 93 94 95 96 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 92 def self._load(array) object, dereferencer = Marshal.load(array) new(object: object, dereferencer: dereferencer) end |
Instance Method Details
#_dump(_) ⇒ Object
88 89 90 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 88 def _dump(_) Marshal.dump([object, dereferencer]) end |
#parsed_response ⇒ Object
102 103 104 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 102 def parsed_response self end |
#private? ⇒ Bool
It’s not publicly available
84 85 86 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 84 def private? !public? && !unlisted? end |
#public? ⇒ Bool
Is this a public post? A post is public when it’s addressed to the public or doesn’t have a recipient (like Like)
68 69 70 71 72 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 68 def public? recipients = [slice(*%w[audience to]).values].flatten recipients.empty? || recipients.include?(PUBLIC) end |
#success? ⇒ Boolean
98 99 100 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 98 def success? true end |
#unlisted? ⇒ Bool
Is it unlisted?
77 78 79 |
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 77 def unlisted? [self['cc']].flatten.include? PUBLIC end |