Class: Coarnotify::Core::Notify::NotifyItem

Inherits:
NotifyPatternPart show all
Defined in:
lib/coarnotify/core/notify.rb

Overview

Default class to represent an item in the COAR Notify pattern. Items are used to represent the ietf:item property in the notification patterns

Specific patterns may need to extend this class to provide their specific behaviours and validation

Instance Attribute Summary

Attributes inherited from NotifyBase

#properties_by_reference, #validate_properties, #validate_stream_on_construct, #validators

Instance Method Summary collapse

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

#media_typeString

Get the mediaType property of the item

Returns:

  • (String)

    the media type



740
741
742
# File 'lib/coarnotify/core/notify.rb', line 740

def media_type
  get_property(NotifyProperties::MEDIA_TYPE)
end

#media_type=(value) ⇒ Object

Set the mediaType property of the item

Parameters:

  • value (String)

    the media type to set



747
748
749
# File 'lib/coarnotify/core/notify.rb', line 747

def media_type=(value)
  set_property(NotifyProperties::MEDIA_TYPE, value)
end

#validateBoolean

Validate the item. This overrides the base validation, as objects only absolutely require an id property, so the base requirement for a type is relaxed.

Returns:

  • (Boolean)

    true if valid, otherwise raises ValidationError



755
756
757
758
759
760
761
762
# File 'lib/coarnotify/core/notify.rb', line 755

def validate
  ve = ValidationError.new

  required_and_validate(ve, ActivityStreams2::Properties::ID, id)

  raise ve if ve.has_errors?
  true
end