Class: Coarnotify::Patterns::Reject
- Inherits:
-
Core::Notify::NotifyPattern
- Object
- Core::Notify::NotifyBase
- Core::Notify::NotifyPattern
- Coarnotify::Patterns::Reject
- Defined in:
- lib/coarnotify/patterns/reject.rb
Overview
Pattern to represent a Reject notification coar-notify.net/specification/1.0.0/reject/
Instance Attribute Summary
Attributes inherited from Core::Notify::NotifyBase
#properties_by_reference, #validate_properties, #validate_stream_on_construct, #validators
Class Method Summary collapse
-
.type_constant ⇒ Object
The Reject type.
Instance Method Summary collapse
-
#validate ⇒ Boolean
Validate the Reject pattern.
Methods included from Core::Notify::SummaryMixin
Methods included from Core::Notify::NestedPatternObjectMixin
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_constant ⇒ Object
The Reject type
16 17 18 |
# File 'lib/coarnotify/patterns/reject.rb', line 16 def self.type_constant Core::ActivityStreams2::ActivityStreamsTypes::REJECT end |
Instance Method Details
#validate ⇒ Boolean
Validate the Reject pattern.
In addition to the base validation, this:
-
Makes inReplyTo required
-
Requires the inReplyTo value to be the same as the object.id value
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/coarnotify/patterns/reject.rb', line 28 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 |