Class: DistributedPress::V1::Social::Reference
- Inherits:
-
Object
- Object
- DistributedPress::V1::Social::Reference
- Extended by:
- Forwardable
- Defined in:
- lib/distributed_press/v1/social/reference.rb
Overview
A lazy loaded reference to a remote object that can access its attributes directly.
Constant Summary collapse
- PUBLIC =
Public addressing doesn’t lead to an activity
'https://www.w3.org/ns/activitystreams#Public'
Instance Attribute Summary collapse
- #dereferencer ⇒ DistributedPress::V1::Social::Dereferencer readonly
- #uri ⇒ String readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(uri:, dereferencer:, object: nil) ⇒ Reference
constructor
A new instance of Reference.
- #inspect ⇒ Object
-
#object ⇒ HTTParty::Response
Fetches the remote object once.
-
#private? ⇒ Bool
It’s not publicly available.
-
#public? ⇒ Bool
Is this a public post?.
-
#unlisted? ⇒ Bool
Is it unlisted?.
Constructor Details
#initialize(uri:, dereferencer:, object: nil) ⇒ Reference
Returns a new instance of Reference.
25 26 27 28 29 |
# File 'lib/distributed_press/v1/social/reference.rb', line 25 def initialize(uri:, dereferencer:, object: nil) @object = object @uri = uri @dereferencer = dereferencer end |
Instance Attribute Details
#dereferencer ⇒ DistributedPress::V1::Social::Dereferencer (readonly)
20 21 22 |
# File 'lib/distributed_press/v1/social/reference.rb', line 20 def dereferencer @dereferencer end |
#uri ⇒ String (readonly)
17 18 19 |
# File 'lib/distributed_press/v1/social/reference.rb', line 17 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/distributed_press/v1/social/reference.rb', line 31 def ==(other) case other when String then uri == other when Reference then uri == other.uri else false end end |
#inspect ⇒ Object
68 69 70 |
# File 'lib/distributed_press/v1/social/reference.rb', line 68 def inspect "#{self.class.name}(#{uri})" end |
#object ⇒ HTTParty::Response
Fetches the remote object once
43 44 45 |
# File 'lib/distributed_press/v1/social/reference.rb', line 43 def object @object ||= dereferencer.get(uri: uri) end |
#private? ⇒ Bool
It’s not publicly available
64 65 66 |
# File 'lib/distributed_press/v1/social/reference.rb', line 64 def private? !public? && !unlisted? end |
#public? ⇒ Bool
Is this a public post?
50 51 52 |
# File 'lib/distributed_press/v1/social/reference.rb', line 50 def public? [slice(*%w[audience to]).values].flatten.include? PUBLIC end |
#unlisted? ⇒ Bool
Is it unlisted?
57 58 59 |
# File 'lib/distributed_press/v1/social/reference.rb', line 57 def unlisted? [self['cc']].flatten.include? PUBLIC end |