Module: Nom::XML::Decorators::Terminology
- Defined in:
- lib/nom/xml/decorators/terminology.rb
Instance Method Summary collapse
- #method_missing(method, *args, &block) ⇒ Object
-
#respond_to_missing?(method, private = false) ⇒ Boolean
As of ruby 2.0, respond_to includes an optional 2nd arg: a boolean controlling whether private methods are targeted.
- #respond_to_without_terms?(method, regular = true) ⇒ Boolean
-
#terms ⇒ Object
Get the terms associated with this node.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nom/xml/decorators/terminology.rb', line 2 def method_missing method, *args, &block if self.term_accessors[method.to_sym] define_term_method(method, self.term_accessors[method.to_sym]) self.send(method, *args, &block) else begin self.document.template_registry.send(method, self, *args, &block) rescue NameError super end end end |
Instance Method Details
#respond_to_missing?(method, private = false) ⇒ Boolean
As of ruby 2.0, respond_to includes an optional 2nd arg:
a boolean controlling whether private methods are targeted.
We don’t actually care for term accessors (none private).
23 24 25 |
# File 'lib/nom/xml/decorators/terminology.rb', line 23 def respond_to_missing? method, private = false super || self.term_accessors[method.to_sym] end |
#respond_to_without_terms?(method, regular = true) ⇒ Boolean
16 17 18 |
# File 'lib/nom/xml/decorators/terminology.rb', line 16 def respond_to_without_terms?(method, regular = true) methods(regular).include?(method) end |
#terms ⇒ Object
Get the terms associated with this node
29 30 31 |
# File 'lib/nom/xml/decorators/terminology.rb', line 29 def terms @terms ||= self.ancestors.map { |p| p.term_accessors(self).map { |keys, values| values } }.flatten.compact.uniq end |