Class: DistributedPress::V1::Social::Reference

Inherits:
Object
  • Object
show all
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

Returns:

  • (String)
'https://www.w3.org/ns/activitystreams#Public'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, dereferencer:, object: nil) ⇒ Reference

Returns a new instance of Reference.

Parameters:



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

#dereferencerDistributedPress::V1::Social::Dereferencer (readonly)



20
21
22
# File 'lib/distributed_press/v1/social/reference.rb', line 20

def dereferencer
  @dereferencer
end

#uriString (readonly)

Returns:

  • (String)


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

#inspectObject



47
48
49
# File 'lib/distributed_press/v1/social/reference.rb', line 47

def inspect
  "#{self.class.name}(#{uri})"
end

#objectHTTParty::Response

Fetches the remote object once

Returns:

  • (HTTParty::Response)


43
44
45
# File 'lib/distributed_press/v1/social/reference.rb', line 43

def object
  @object ||= dereferencer.get(uri: uri)
end