Module: DocumentBuilder::Coercion::ClassMethods
- Defined in:
- lib/document_builder/coercion.rb
Instance Method Summary collapse
Instance Method Details
#call(document, params = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/document_builder/coercion.rb', line 8 def call(document, params = {}) root = @xpath || params[:xpath] unless document.name == root document = document.at_xpath(root) end document.nil? ? nil : self.coerce(document) end |
#coerce(document) ⇒ Object
17 18 19 |
# File 'lib/document_builder/coercion.rb', line 17 def coerce(document) self.new(document) end |
#xpath(value) ⇒ Object
4 5 6 |
# File 'lib/document_builder/coercion.rb', line 4 def xpath(value) @xpath = value end |