Class: Jekyll::Drops::ActivityDrop
- Inherits:
-
Drop
- Object
- Drop
- Jekyll::Drops::ActivityDrop
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll/drops/activity_drop.rb
Overview
Converts an activity into a liquid drop that can be dereferenced on demand.
Instance Method Summary collapse
-
#all_items ⇒ Array
Iterate over all public items of a collection.
-
#available ⇒ Object
This means we could dereference the object, Liquid can use it to check if it’s possible to use it.
- #fallback_data ⇒ Object
-
#initialize(obj) ⇒ ActivityDrop
constructor
A new instance of ActivityDrop.
- #to_s ⇒ Object
Constructor Details
#initialize(obj) ⇒ ActivityDrop
Returns a new instance of ActivityDrop.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/jekyll/drops/activity_drop.rb', line 79 def initialize(obj) id = case obj when Jekyll::Page obj['id'] || obj.url when DistributedPress::V1::Social::ReferencedObject obj['id'] end raise StandardError unless id Jekyll.logger.info 'ActivityPub:', "Referencing #{id}" @original_obj = obj @@objects ||= {} @obj = @@objects[id] ||= case obj when Jekyll::Page DistributedPress::V1::Social::ReferencedObject.new(object: JSON.parse(obj.to_json), dereferencer: Jekyll::ActivityPub::Notifier.dereferencer) when DistributedPress::V1::Social::ReferencedObject obj else raise StandardError end rescue StandardError => e Jekyll.logger.warn 'ActivityPub:', "Error" end |
Instance Method Details
#all_items ⇒ Array
Iterate over all public items of a collection
67 68 69 70 71 |
# File 'lib/jekyll/drops/activity_drop.rb', line 67 def all_items return nil unless @obj.respond_to?(:each) @all_items ||= @obj.each.to_a.uniq { |x| x.uri }.reject(&:private?) end |
#available ⇒ Object
This means we could dereference the object, Liquid can use it to check if it’s possible to use it.
75 76 77 |
# File 'lib/jekyll/drops/activity_drop.rb', line 75 def available true end |
#fallback_data ⇒ Object
110 111 112 |
# File 'lib/jekyll/drops/activity_drop.rb', line 110 def fallback_data @obj end |
#to_s ⇒ Object
106 107 108 |
# File 'lib/jekyll/drops/activity_drop.rb', line 106 def to_s @obj.object.to_json end |