Module: Duxml::History
- Includes:
- Duxml, Reportable
- Included in:
- HistoryClass
- Defined in:
- lib/duxml/meta/history.rb,
lib/duxml/meta/history.rb
Overview
monitors XML Elements for changes and GrammarClass for errors, recording them and saving to Meta file
Constant Summary
Constants included from Duxml
Constants included from Meta
Instance Attribute Summary
Attributes included from Duxml
Attributes included from Saxer
Class Method Summary collapse
-
.xml ⇒ Element
used when creating a new metadata file for a static XML file.
Instance Method Summary collapse
-
#description ⇒ String
Returns entire history, calling #description on each event in chronological order.
-
#grammar ⇒ GrammarClass
Grammar that is observing this history’s events.
-
#inspect ⇒ String
Shortened self description for debugging.
-
#latest ⇒ ChangeClass, ErrorClass
The latest event.
-
#strict?(harsh_or_kind = nil) ⇒ Boolean
Toggles (true by default) whether History will raise exception or tolerate qualify errors.
- #update(type, *args) ⇒ Object
Methods included from Reportable
Methods included from Duxml
#create, #load, #log, #relaxng, #save, #validate
Methods included from Meta
Methods included from Saxer
Class Method Details
Instance Method Details
#description ⇒ String
Returns entire history, calling #description on each event in chronological order
70 71 72 73 74 75 |
# File 'lib/duxml/meta/history.rb', line 70 def description "history follows: \n" + events.reverse.collect do |change_or_error| change_or_error.description end.join("\n") end |
#grammar ⇒ GrammarClass
Returns grammar that is observing this history’s events.
60 61 62 |
# File 'lib/duxml/meta/history.rb', line 60 def grammar @observer_peers.first.first if @observer_peers and @observer_peers.any? and @observer_peers.first.any? end |
#inspect ⇒ String
Returns shortened self description for debugging.
65 66 67 |
# File 'lib/duxml/meta/history.rb', line 65 def inspect "#<#{self.class.to_s} #{object_id}: @events=#{nodes.size}>" end |
#latest ⇒ ChangeClass, ErrorClass
Returns the latest event.
55 56 57 |
# File 'lib/duxml/meta/history.rb', line 55 def latest events[0] end |
#strict?(harsh_or_kind = nil) ⇒ Boolean
Returns toggles (true by default) whether History will raise exception or tolerate qualify errors.
49 50 51 52 |
# File 'lib/duxml/meta/history.rb', line 49 def strict?(harsh_or_kind=nil) @strict = harsh_or_kind.nil? ? @strict : harsh_or_kind @strict end |
#update(type, *args) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/duxml/meta/history.rb', line 79 def update(type, *args) change_class = Duxml::const_get "#{type.to_s}Class".to_sym change_comp = change_class.new *args @nodes.unshift change_comp changed notify_observers(change_comp) unless change_comp.respond_to?(:error?) raise(Exception, change_comp.description) if strict? && type == :QualifyError end |