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, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names

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:



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

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



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

property :local, :boolean

#parentRelatedEntity (readonly)

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

Returns:



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

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



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

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:



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

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:



29
30
31
32
33
# File 'lib/diaspora_federation/entities/related_entity.rb', line 29

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

#to_jsonObject



53
54
55
# File 'lib/diaspora_federation/entities/related_entity.rb', line 53

def to_json
  nil
end

#to_xmlObject



48
49
50
# File 'lib/diaspora_federation/entities/related_entity.rb', line 48

def to_xml
  nil
end