Module: Coarnotify::Core::Notify::NestedPatternObjectMixin
- Included in:
- Patterns::Accept, Patterns::Reject, Patterns::TentativelyAccept, Patterns::TentativelyReject, Patterns::UndoOffer
- Defined in:
- lib/coarnotify/core/notify.rb
Overview
A mixin to add to a pattern which can override the default object property to return a full nested pattern from the object property, rather than the default NotifyObject
This mixin needs to be included first, as it overrides the object property of the NotifyPattern class.
For example:
class MySpecialPattern < NotifyPattern
include NestedPatternObjectMixin
end
Instance Method Summary collapse
-
#object ⇒ NotifyPattern, ...
Retrieve an object as it’s correctly typed pattern, falling back to a default NotifyObject if no pattern matches.
-
#object=(value) ⇒ Object
Set the object property.
Instance Method Details
#object ⇒ NotifyPattern, ...
Retrieve an object as it’s correctly typed pattern, falling back to a default NotifyObject if no pattern matches
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
# File 'lib/coarnotify/core/notify.rb', line 783 def object o = get_property(ActivityStreams2::Properties::OBJECT) if o # Try to get the factory class if it's available if defined?(::Coarnotify::Factory::COARNotifyFactory) begin nested = ::Coarnotify::Factory::COARNotifyFactory.get_by_object(o.dup, validate_stream_on_construct: false, validate_properties: @validate_properties, validators: @validators, validation_context: nil) # don't supply a validation context, as these objects are not typical nested objects return nested if nested rescue => e # Fall back to generic object if factory fails end end # if we are unable to construct the typed nested object, just return a generic object NotifyObject.new(stream: o.dup, validate_stream_on_construct: false, validate_properties: @validate_properties, validators: @validators, validation_context: ActivityStreams2::Properties::OBJECT) end end |
#object=(value) ⇒ Object
Set the object property
810 811 812 |
# File 'lib/coarnotify/core/notify.rb', line 810 def object=(value) set_property(ActivityStreams2::Properties::OBJECT, value.doc) end |