Class: Coarnotify::Core::Notify::NotifyObject
- Inherits:
-
NotifyPatternPart
- Object
- NotifyBase
- NotifyPatternPart
- Coarnotify::Core::Notify::NotifyObject
- Defined in:
- lib/coarnotify/core/notify.rb
Overview
Default class to represent an object in the COAR Notify pattern. Objects can be used for object or context properties in notify patterns
Specific patterns may need to extend this class to provide their specific behaviours and validation
Direct Known Subclasses
Patterns::AnnounceEndorsementContext, Patterns::AnnounceRelationshipObject, Patterns::AnnounceReviewContext, Patterns::AnnounceReviewObject, Patterns::AnnounceServiceResultContext, Patterns::AnnounceServiceResultObject, Patterns::RequestEndorsementObject, Patterns::RequestReviewObject
Instance Attribute Summary
Attributes inherited from NotifyBase
#properties_by_reference, #validate_properties, #validate_stream_on_construct, #validators
Instance Method Summary collapse
-
#cite_as ⇒ String
Get the ietf:cite-as property of the object.
-
#cite_as=(value) ⇒ Object
Set the ietf:cite-as property of the object.
-
#item ⇒ NotifyItem?
Get the ietf:item property of the object.
-
#item=(value) ⇒ Object
Set the ietf:item property of the object.
-
#triple ⇒ Array<String>
Get object, relationship and subject properties as a relationship triple.
-
#triple=(value) ⇒ Object
Set object, relationship and subject properties as a relationship triple.
-
#validate ⇒ Boolean
Validate the object.
Methods inherited from NotifyPatternPart
#allowed_types, allowed_types, default_type, #initialize, #type=
Methods inherited from 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::NotifyPatternPart
Instance Method Details
#cite_as ⇒ String
Get the ietf:cite-as property of the object
631 632 633 |
# File 'lib/coarnotify/core/notify.rb', line 631 def cite_as get_property(NotifyProperties::CITE_AS) end |
#cite_as=(value) ⇒ Object
Set the ietf:cite-as property of the object
638 639 640 |
# File 'lib/coarnotify/core/notify.rb', line 638 def cite_as=(value) set_property(NotifyProperties::CITE_AS, value) end |
#item ⇒ NotifyItem?
Get the ietf:item property of the object
645 646 647 648 649 650 651 652 653 |
# File 'lib/coarnotify/core/notify.rb', line 645 def item i = get_property(NotifyProperties::ITEM) if i NotifyItem.new(stream: i, validate_stream_on_construct: false, validate_properties: @validate_properties, validators: @validators, validation_context: NotifyProperties::ITEM, properties_by_reference: @properties_by_reference) end end |
#item=(value) ⇒ Object
Set the ietf:item property of the object
658 659 660 |
# File 'lib/coarnotify/core/notify.rb', line 658 def item=(value) set_property(NotifyProperties::ITEM, value) end |
#triple ⇒ Array<String>
Get object, relationship and subject properties as a relationship triple
665 666 667 668 669 670 |
# File 'lib/coarnotify/core/notify.rb', line 665 def triple obj = get_property(ActivityStreams2::Properties::OBJECT_TRIPLE) rel = get_property(ActivityStreams2::Properties::RELATIONSHIP_TRIPLE) subj = get_property(ActivityStreams2::Properties::SUBJECT_TRIPLE) [obj, rel, subj] end |
#triple=(value) ⇒ Object
Set object, relationship and subject properties as a relationship triple
675 676 677 678 679 680 |
# File 'lib/coarnotify/core/notify.rb', line 675 def triple=(value) obj, rel, subj = value set_property(ActivityStreams2::Properties::OBJECT_TRIPLE, obj) set_property(ActivityStreams2::Properties::RELATIONSHIP_TRIPLE, rel) set_property(ActivityStreams2::Properties::SUBJECT_TRIPLE, subj) end |
#validate ⇒ Boolean
Validate the object. This overrides the base validation, as objects only absolutely require an id property, so the base requirement for a type is relaxed.
686 687 688 689 690 691 692 693 |
# File 'lib/coarnotify/core/notify.rb', line 686 def validate ve = ValidationError.new required_and_validate(ve, ActivityStreams2::Properties::ID, id) raise ve if ve.has_errors? true end |