Module: Duxml::Rule
- Includes:
- Reportable
- Included in:
- RuleClass
- Defined in:
- lib/duxml/meta/grammar/rule.rb,
lib/duxml/meta/grammar/rule.rb
Overview
contains methods to apply Duxml::RuleClass to XML edit or validate events
Instance Attribute Summary
Attributes included from Reportable
Instance Method Summary collapse
-
#applies_to?(change_or_pattern) ⇒ Boolean
Whether this rule does in fact apply.
-
#description ⇒ String
Default description for a Rule.
-
#history ⇒ HistoryClass
History to which this rule will report errors.
-
#qualify(change_or_pattern) ⇒ Boolean
Duxml::Rule’s #qualify is only used to report errors found by its subclasses’ #qualify methods.
Methods included from Reportable
Instance Method Details
#applies_to?(change_or_pattern) ⇒ Boolean
Returns whether this rule does in fact apply.
48 49 50 51 |
# File 'lib/duxml/meta/grammar/rule.rb', line 48 def applies_to?(change_or_pattern) pattern_type = change_or_pattern.subject.name subject == pattern_type end |
#description ⇒ String
Returns default description for a Rule.
54 55 56 57 |
# File 'lib/duxml/meta/grammar/rule.rb', line 54 def description statement_str = (statement.is_a?(String) ? statement : statement.inspect).gsub('\b','') %(#{relationship.capitalize} Rule that <#{subject}>'s #{relationship} must match '#{statement_str}') end |
#history ⇒ HistoryClass
Returns history to which this rule will report errors.
42 43 44 |
# File 'lib/duxml/meta/grammar/rule.rb', line 42 def history @observer_peers.first.first if @observer_peers.any? and @observer_peers.first.any? end |
#qualify(change_or_pattern) ⇒ Boolean
Duxml::Rule’s #qualify is only used to report errors found by its subclasses’ #qualify methods
35 36 37 38 39 |
# File 'lib/duxml/meta/grammar/rule.rb', line 35 def qualify(change_or_pattern) type = (change_or_pattern.respond_to?(:time_stamp)) ? :QualifyError : :ValidateError report(type, change_or_pattern) false end |