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, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names
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
11 |
# File 'lib/diaspora_federation/entities/participation.rb', line 11 property :author, :string, xml_name: :diaspora_handle |
#guid ⇒ String (readonly)
A random string of at least 16 chars
17 |
# File 'lib/diaspora_federation/entities/participation.rb', line 17 property :guid, :string |
#parent_guid ⇒ String (readonly)
Returns parent guid.
22 |
# File 'lib/diaspora_federation/entities/participation.rb', line 22 property :parent_guid, :string |
#parent_type ⇒ String (readonly)
A string describing a type of the target to subscribe on Currently only “Post” is supported.
28 |
# File 'lib/diaspora_federation/entities/participation.rb', line 28 property :parent_type, :string, xml_name: :target_type |
Class Method Details
.from_hash(hash) ⇒ Entity
Validate that the parent is local.
45 46 47 |
# File 'lib/diaspora_federation/entities/participation.rb', line 45 def self.from_hash(hash) super.tap(&:validate_parent) end |
Instance Method Details
#to_s ⇒ String
Returns string representation of this object.
31 32 33 |
# File 'lib/diaspora_federation/entities/participation.rb', line 31 def to_s "#{super}:#{parent_type}:#{parent_guid}" end |
#validate_parent ⇒ Object
Validates that the parent exists and the parent author is local
36 37 38 39 |
# File 'lib/diaspora_federation/entities/participation.rb', line 36 def validate_parent parent = DiasporaFederation.callbacks.trigger(:fetch_related_entity, parent_type, parent_guid) raise ParentNotLocal, "obj=#{self}" unless parent && parent.local end |