Module: DocumentBuilder::Collection::ClassMethods

Defined in:
lib/document_builder/collection.rb

Instance Method Summary collapse

Instance Method Details

#call(document, params = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/document_builder/collection.rb', line 4

def call(document, params = {})
  root = @xpath || params[:xpath]
  unless document.name == root
    document = document.xpath(root)
  end

  document.nil? ? nil : self.coerce(document)
end

#collection(value, xpath, parser) ⇒ Object



13
14
15
# File 'lib/document_builder/collection.rb', line 13

def collection(value, xpath, parser)
  @collection = Attribute.new(value, xpath, parser)
end

#inherited(subclass) ⇒ Object



17
18
19
20
# File 'lib/document_builder/collection.rb', line 17

def inherited(subclass)
  subclass.instance_variable_set(:@collection, @collection)
  super
end