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
Instance Attribute Summary
Attributes included from Reportable
Attributes included from Duxml
Attributes included from Saxer
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?(strict_or_false = nil) ⇒ Boolean
Toggles (true by default) whether History will raise exception or tolerate qualify errors.
- #update(type, *args) ⇒ Object
-
#xml ⇒ Doc
used when creating a new metadata file for a static XML file.
Methods included from Reportable
Methods included from Duxml
Methods included from Saxer
Instance Method Details
#description ⇒ String
Returns entire history, calling #description on each event in chronological order
71 72 73 74 75 76 |
# File 'lib/duxml/meta/history.rb', line 71 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.
61 62 63 |
# File 'lib/duxml/meta/history.rb', line 61 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.
66 67 68 |
# File 'lib/duxml/meta/history.rb', line 66 def inspect "#<#{self.class.to_s} #{object_id}: @events=#{nodes.size}>" end |
#latest ⇒ ChangeClass, ErrorClass
Returns the latest event.
56 57 58 |
# File 'lib/duxml/meta/history.rb', line 56 def latest events[0] end |
#strict?(strict_or_false = nil) ⇒ Boolean
Returns toggles (true by default) whether History will raise exception or tolerate qualify errors.
51 52 53 |
# File 'lib/duxml/meta/history.rb', line 51 def strict?(strict_or_false=nil) @strict = strict_or_false.nil? ? @strict : strict_or_false end |
#update(type, *args) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/duxml/meta/history.rb', line 80 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 |