Method: Wgit::Model.document

Defined in:
lib/wgit/database/model.rb

.document(doc) ⇒ Hash

The data model for a Wgit::Document collection object.

Parameters:

Returns:

  • (Hash)

    The Document model ready for DB insertion.



24
25
26
27
28
29
30
31
# File 'lib/wgit/database/model.rb', line 24

def self.document(doc)
  raise 'doc must respond_to? :to_h' unless doc.respond_to?(:to_h)

  model = doc.to_h(include_html: false, include_score: false)
  model['url'] = url(doc.url) # Expand Url String into full object.

  select_bson_types(model)
end