Class: DiasporaFederation::Entities::Participation
- Inherits:
-
DiasporaFederation::Entity
- Object
- DiasporaFederation::Entity
- DiasporaFederation::Entities::Participation
- Defined in:
- lib/diaspora_federation/entities/participation.rb
Overview
Participation is sent to subscribe a user on updates for some post.
Defined Under Namespace
Classes: ParentNotLocal
Constant Summary
Constants inherited from DiasporaFederation::Entity
DiasporaFederation::Entity::ENTITY_NAME_REGEX, DiasporaFederation::Entity::INVALID_XML_REGEX
Instance Attribute Summary collapse
-
#author ⇒ String
readonly
The diaspora* ID of the author.
-
#guid ⇒ String
readonly
A random string of at least 16 chars.
-
#parent_guid ⇒ String
readonly
Parent guid.
-
#parent_type ⇒ String
readonly
A string describing a type of the target to subscribe on Currently only “Post” is supported.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Entity
Validate that the parent is local.
Instance Method Summary collapse
-
#to_s ⇒ String
String representation of this object.
-
#validate_parent ⇒ Object
Validates that the parent exists and the parent author is local.
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
Constructor Details
This class inherits a constructor from DiasporaFederation::Entity
Instance Attribute Details
#author ⇒ String (readonly)
The diaspora* ID of the author
13 |
# File 'lib/diaspora_federation/entities/participation.rb', line 13 property :author, :string |
#guid ⇒ String (readonly)
A random string of at least 16 chars
19 |
# File 'lib/diaspora_federation/entities/participation.rb', line 19 property :guid, :string |
#parent_guid ⇒ String (readonly)
Returns parent guid.
24 |
# File 'lib/diaspora_federation/entities/participation.rb', line 24 property :parent_guid, :string |
#parent_type ⇒ String (readonly)
A string describing a type of the target to subscribe on Currently only “Post” is supported.
30 |
# File 'lib/diaspora_federation/entities/participation.rb', line 30 property :parent_type, :string |
Class Method Details
.from_hash(hash) ⇒ Entity
Validate that the parent is local.
47 48 49 |
# File 'lib/diaspora_federation/entities/participation.rb', line 47 def self.from_hash(hash) super.tap(&:validate_parent) end |
Instance Method Details
#to_s ⇒ String
Returns string representation of this object.
33 34 35 |
# File 'lib/diaspora_federation/entities/participation.rb', line 33 def to_s "#{super}:#{parent_type}:#{parent_guid}" end |
#validate_parent ⇒ Object
Validates that the parent exists and the parent author is local
38 39 40 41 |
# File 'lib/diaspora_federation/entities/participation.rb', line 38 def validate_parent parent = DiasporaFederation.callbacks.trigger(:fetch_related_entity, parent_type, parent_guid) raise ParentNotLocal, "obj=#{self}" unless parent&.local end |