class DiasporaFederation::Entities::Participation

Participation is sent to subscribe a user on updates for some post.

@see Validators::Participation

Public Class Methods

from_hash(hash) click to toggle source

Validate that the parent is local. @see Entity.from_hash @param [Hash] hash entity initialization hash @return [Entity] instance

Calls superclass method
# File lib/diaspora_federation/entities/participation.rb, line 47
def self.from_hash(hash)
  super.tap(&:validate_parent)
end

Public Instance Methods

to_s() click to toggle source

@return [String] string representation of this object

# File lib/diaspora_federation/entities/participation.rb, line 33
def to_s
  "#{super}:#{parent_type}:#{parent_guid}"
end
validate_parent() click to toggle source

Validates that the parent exists and the parent author is local

# 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