class Dor::EventsDS
Public Class Methods
Default EventsDS
xml
# File lib/dor/datastreams/events_ds.rb, line 18 def self.xml_template builder = Nokogiri::XML::Builder.new do |xml| xml.events end builder.doc end
Public Instance Methods
Adds an event to the datastream @param [String] type a tag used to group events together. Sets the type attribute for the event @param [String] who who is responsible for this event. Sets the who attribute for the event @param [String] message what happened. Sets the content of the event with this message
# File lib/dor/datastreams/events_ds.rb, line 33 def add_event(type, who, message) ng_xml_will_change! ev = ng_xml.create_element 'event', message, type: type, who: who, when: Time.now.utc.xmlschema ng_xml.root.add_child(ev) end
Returns all the events in the datastream @yield [type, who, timestamp, message] The values of the current event @yieldparam [String] type tag for this particular event. Value of the 'type' attribute @yieldparam [String] who thing responsible for creating the event. Value of the 'who' attribute @yieldparam [Time] timestamp when this event was logged. Value of the 'when' attribute @yieldparam [String] message what happened. Content of the event node
# File lib/dor/datastreams/events_ds.rb, line 58 def each_event find_by_terms(:event).each do |node| yield(node['type'], node['who'], Time.parse(node['when']), node.content) end end
# File lib/dor/datastreams/events_ds.rb, line 25 def ensure_non_versionable self.versionable = 'false' end
Finds events with the desired type attribute @param [String] tag events where type == tag will be returned @yield [who, timestamp, message] The values of the current event @yieldparam [String] who thing responsible for creating the event. Value of the 'who' attribute @yieldparam [Time] timestamp when this event was logged. Value of the 'when' attribute @yieldparam [String] message what happened. Content of the event node
# File lib/dor/datastreams/events_ds.rb, line 46 def find_events_by_type(tag) find_by_terms(:event).xpath("//event[@type='#{tag}']").each do |node| yield(node['who'], Time.parse(node['when']), node.content) end end
maintain AF < 8 indexing behavior
# File lib/dor/datastreams/events_ds.rb, line 65 def prefix '' end