Class: DiasporaFederation::Entities::Retraction

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

Overview

This entity represents a claim of deletion of a previously federated entity.

Defined Under Namespace

Classes: TargetNotFound

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_json, from_xml, #initialize, #to_h, #to_json, #to_xml

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 person who deletes the entity

Returns:

  • (String)

    diaspora* ID

See Also:



13
# File 'lib/diaspora_federation/entities/retraction.rb', line 13

property :author, :string

#targetRelatedEntity (readonly)

Target entity

Returns:



28
# File 'lib/diaspora_federation/entities/retraction.rb', line 28

entity :target, Entities::RelatedEntity

#target_guidString (readonly)

Guid of the entity to be deleted

Returns:

  • (String)

    target guid



18
# File 'lib/diaspora_federation/entities/retraction.rb', line 18

property :target_guid, :string

#target_typeString (readonly)

A string describing the type of the target

Returns:

  • (String)

    target type



23
# File 'lib/diaspora_federation/entities/retraction.rb', line 23

property :target_type, :string

Class Method Details

.from_hash(hash) ⇒ Retraction

Returns instance.

Returns:

See Also:



46
47
48
49
# File 'lib/diaspora_federation/entities/retraction.rb', line 46

def self.from_hash(hash)
  hash[:target] = fetch_target(hash[:target_type], hash[:target_guid])
  new(hash)
end

Instance Method Details

#sender_valid?(sender) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/diaspora_federation/entities/retraction.rb', line 30

def sender_valid?(sender)
  case target_type
  when "Comment", "Like", "PollParticipation"
    [target.root.author, target.author].include?(sender)
  else
    sender == target.author
  end
end

#to_sString

Returns string representation of this object.

Returns:

  • (String)

    string representation of this object



40
41
42
# File 'lib/diaspora_federation/entities/retraction.rb', line 40

def to_s
  "Retraction:#{target_type}:#{target_guid}"
end