Class: Dor::EventsDS
- Inherits:
-
ActiveFedora::OmDatastream
- Object
- ActiveFedora::OmDatastream
- Dor::EventsDS
- Defined in:
- lib/dor/datastreams/events_ds.rb
Class Method Summary collapse
-
.xml_template ⇒ Object
Default EventsDS xml.
Instance Method Summary collapse
-
#add_event(type, who, message) ⇒ Object
Adds an event to the datastream.
-
#each_event {|type, who, timestamp, message| ... } ⇒ Object
Returns all the events in the datastream.
- #ensure_non_versionable ⇒ Object
-
#find_events_by_type(tag) {|who, timestamp, message| ... } ⇒ Object
Finds events with the desired type attribute.
-
#prefix ⇒ Object
maintain AF < 8 indexing behavior.
Class Method Details
.xml_template ⇒ Object
Default EventsDS xml
18 19 20 21 22 23 |
# 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 |
Instance Method Details
#add_event(type, who, message) ⇒ Object
Adds an event to the datastream
33 34 35 36 37 38 |
# File 'lib/dor/datastreams/events_ds.rb', line 33 def add_event(type, who, ) ng_xml_will_change! ev = ng_xml.create_element 'event', , type: type, who: who, when: Time.now.utc.xmlschema ng_xml.root.add_child(ev) end |
#each_event {|type, who, timestamp, message| ... } ⇒ Object
Returns all the events in the datastream
58 59 60 61 62 |
# 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 |
#ensure_non_versionable ⇒ Object
25 26 27 |
# File 'lib/dor/datastreams/events_ds.rb', line 25 def ensure_non_versionable self.versionable = 'false' end |
#find_events_by_type(tag) {|who, timestamp, message| ... } ⇒ Object
Finds events with the desired type attribute
46 47 48 49 50 |
# 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 |
#prefix ⇒ Object
maintain AF < 8 indexing behavior
65 66 67 |
# File 'lib/dor/datastreams/events_ds.rb', line 65 def prefix '' end |