Class: DistributedPress::V1::Social::ReferencedObject

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/distributed_press/v1/social/referenced_object.rb

Overview

TODO:

Merge with Reference

An object with external references

Direct Known Subclasses

Collection

Constant Summary collapse

PUBLIC =

Public addressing doesn’t lead to an activity

Returns:

  • (String)
'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

Class Method Summary collapse

Instance Method Summary collapse

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

#dereferencerObject (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

#objectObject (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

#referencedObject (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_responseObject



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

Returns:

  • (Bool)


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)

Returns:

  • (Bool)


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

Returns:

  • (Boolean)


98
99
100
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 98

def success?
  true
end

#unlisted?Bool

Is it unlisted?

Returns:

  • (Bool)


77
78
79
# File 'lib/distributed_press/v1/social/referenced_object.rb', line 77

def unlisted?
  [self['cc']].flatten.include? PUBLIC
end