Module: Coarnotify::Core::Notify

Defined in:
lib/coarnotify/core/notify.rb

Overview

This module is home to all the core model objects from which the notify patterns extend

Defined Under Namespace

Modules: NestedPatternObjectMixin, NotifyProperties, NotifyTypes, SummaryMixin Classes: NotifyActor, NotifyBase, NotifyItem, NotifyObject, NotifyPattern, NotifyPatternPart, NotifyService

Constant Summary collapse

NOTIFY_NAMESPACE =

Namespace for COAR Notify, to be used to construct namespaced properties used in COAR Notify Patterns

"https://coar-notify.net"
VALIDATION_RULES =

Validation rules for notify patterns

{
  ActivityStreams2::Properties::ID => {
    "default" => proc { |obj, uri| Validate.absolute_uri(obj, uri) },
    "context" => {
      ActivityStreams2::Properties::CONTEXT => {
        "default" => proc { |obj, url| Validate.url(obj, url) }
      },
      ActivityStreams2::Properties::ORIGIN => {
        "default" => proc { |obj, url| Validate.url(obj, url) }
      },
      ActivityStreams2::Properties::TARGET => {
        "default" => proc { |obj, url| Validate.url(obj, url) }
      },
      NotifyProperties::ITEM => {
        "default" => proc { |obj, url| Validate.url(obj, url) }
      }
    }
  },
  ActivityStreams2::Properties::TYPE => {
    "default" => proc { |obj, value| Validate.type_checker(obj, value) },
    "context" => {
      ActivityStreams2::Properties::ACTOR => {
        "default" => Validate.one_of([
          ActivityStreams2::ActivityStreamsTypes::SERVICE,
          ActivityStreams2::ActivityStreamsTypes::APPLICATION,
          ActivityStreams2::ActivityStreamsTypes::GROUP,
          ActivityStreams2::ActivityStreamsTypes::ORGANIZATION,
          ActivityStreams2::ActivityStreamsTypes::PERSON
        ])
      },
      ActivityStreams2::Properties::OBJECT => {
        "default" => Validate.at_least_one_of(ActivityStreams2::ACTIVITY_STREAMS_OBJECTS)
      },
      ActivityStreams2::Properties::CONTEXT => {
        "default" => Validate.at_least_one_of(ActivityStreams2::ACTIVITY_STREAMS_OBJECTS)
      },
      NotifyProperties::ITEM => {
        "default" => Validate.at_least_one_of(ActivityStreams2::ACTIVITY_STREAMS_OBJECTS + [NotifyTypes::ABOUT_PAGE])
      }
    }
  },
  NotifyProperties::CITE_AS => {
    "default" => proc { |obj, url| Validate.url(obj, url) }
  },
  NotifyProperties::INBOX => {
    "default" => proc { |obj, url| Validate.url(obj, url) }
  },
  ActivityStreams2::Properties::IN_REPLY_TO => {
    "default" => proc { |obj, uri| Validate.absolute_uri(obj, uri) }
  },
  ActivityStreams2::Properties::SUBJECT_TRIPLE => {
    "default" => proc { |obj, uri| Validate.absolute_uri(obj, uri) }
  },
  ActivityStreams2::Properties::OBJECT_TRIPLE => {
    "default" => proc { |obj, uri| Validate.absolute_uri(obj, uri) }
  },
  ActivityStreams2::Properties::RELATIONSHIP_TRIPLE => {
    "default" => proc { |obj, uri| Validate.absolute_uri(obj, uri) }
  }
}.freeze
VALIDATORS =

Default Validator object for all pattern types

Validate::Validator.new(VALIDATION_RULES)