Class: Coarnotify::Patterns::UndoOffer

Inherits:
Core::Notify::NotifyPattern show all
Includes:
Core::Notify::NestedPatternObjectMixin, Core::Notify::SummaryMixin
Defined in:
lib/coarnotify/patterns/undo_offer.rb

Overview

Pattern to represent the Undo Offer notification coar-notify.net/specification/1.0.0/undo-offer/

Instance Attribute Summary

Attributes inherited from Core::Notify::NotifyBase

#properties_by_reference, #validate_properties, #validate_stream_on_construct, #validators

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Core::Notify::SummaryMixin

#summary, #summary=

Methods included from Core::Notify::NestedPatternObjectMixin

#object, #object=

Methods inherited from Core::Notify::NotifyPattern

#actor, #actor=, #context, #context=, #ensure_type_contains, #in_reply_to, #in_reply_to=, #initialize, #object, #object=, #origin, #origin=, #target, #target=

Methods inherited from Core::Notify::NotifyBase

#doc, #get_property, #id, #id=, #initialize, #optional_and_validate, #register_property_validation_error, #required, #required_and_validate, #set_property, #to_jsonld, #type, #type=, #validate_property

Constructor Details

This class inherits a constructor from Coarnotify::Core::Notify::NotifyPattern

Class Method Details

.type_constantObject



15
16
17
# File 'lib/coarnotify/patterns/undo_offer.rb', line 15

def self.type_constant
  Core::ActivityStreams2::ActivityStreamsTypes::UNDO
end

Instance Method Details

#validateBoolean

In addition to the base validation apply the following constraints:

  • The inReplyTo property is required

  • The inReplyTo value must match the object.id value

Returns:

  • (Boolean)

    true if validation passes, otherwise raise a ValidationError



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/coarnotify/patterns/undo_offer.rb', line 25

def validate
  ve = ValidationError.new
  begin
    super
  rescue ValidationError => superve
    ve = superve
  end

  # Technically, no need to validate the value, as this is handled by the superclass,
  # but leaving it in for completeness
  required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)

  objid = object&.id
  if in_reply_to != objid
    ve.add_error(Core::ActivityStreams2::Properties::IN_REPLY_TO,
                 "Expected inReplyTo id to be the same as the nested object id. inReplyTo: #{in_reply_to}, object.id: #{objid}")
  end

  raise ve if ve.has_errors?
  true
end