Class: DiasporaFederation::Entities::RelatedEntity

Inherits:
DiasporaFederation::Entity show all
Defined in:
lib/diaspora_federation/entities/related_entity.rb

Overview

Entity meta informations for a related entity (parent or target of another entity).

Constant Summary

Constants inherited from DiasporaFederation::Entity

DiasporaFederation::Entity::ENTITY_NAME_REGEX, DiasporaFederation::Entity::INVALID_XML_REGEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DiasporaFederation::Entity

class_name, entity_class, entity_name, from_hash, from_json, from_xml, #initialize, #to_h, #to_s

Methods included from PropertiesDSL

#class_props, #default_values, #entity, #missing_props, #optional_props, #property, #resolv_aliases

Methods included from Logging

included

Constructor Details

This class inherits a constructor from DiasporaFederation::Entity

Instance Attribute Details

#authorString (readonly)

The diaspora* ID of the author

Returns:

  • (String)

    diaspora* ID

See Also:



12
# File 'lib/diaspora_federation/entities/related_entity.rb', line 12

property :author, :string

#localBoolean (readonly)

true if the owner of the entity is local on the pod

Returns:

  • (Boolean)

    is it a like or a dislike



17
# File 'lib/diaspora_federation/entities/related_entity.rb', line 17

property :local, :boolean

#parentRelatedEntity (readonly)

Parent if the entity also has a parent (Comment or Like) or nil if it has no parent

Returns:



27
# File 'lib/diaspora_federation/entities/related_entity.rb', line 27

entity :parent, Entities::RelatedEntity, default: nil

#publicBoolean (readonly)

Shows whether the entity is visible to everyone or only to some aspects

Returns:

  • (Boolean)

    is it public



22
# File 'lib/diaspora_federation/entities/related_entity.rb', line 22

property :public, :boolean, default: false

Class Method Details

.fetch(author, type, guid) ⇒ RelatedEntity

Get related entity from the backend or fetch it from remote if not available locally

Returns:



39
40
41
42
43
44
45
46
47
# File 'lib/diaspora_federation/entities/related_entity.rb', line 39

def self.fetch(author, type, guid)
  # Try to fetch locally
  entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, type, guid)
  return entity if entity

  # Fetch and receive entity from remote if not available locally
  Federation::Fetcher.fetch_public(author, type, guid)
  DiasporaFederation.callbacks.trigger(:fetch_related_entity, type, guid)
end

Instance Method Details

#rootRelatedEntity

The root entity, this entity is responsible for relaying relayables

Returns:



31
32
33
34
35
# File 'lib/diaspora_federation/entities/related_entity.rb', line 31

def root
  root = self
  root = root.parent until root.parent.nil?
  root
end

#to_json(*_args) ⇒ Object



55
56
57
# File 'lib/diaspora_federation/entities/related_entity.rb', line 55

def to_json(*_args)
  nil
end

#to_xmlObject



50
51
52
# File 'lib/diaspora_federation/entities/related_entity.rb', line 50

def to_xml
  nil
end