Module: Wgit::Model
- Defined in:
- lib/wgit/database/model.rb
Overview
Module used to build the database collection objects, forming a data model.
Class Method Summary collapse
-
.common_insert_data ⇒ Hash
Common fields when inserting a record into the DB.
-
.common_update_data ⇒ Hash
Common fields when updating a record in the DB.
-
.document(doc) ⇒ Hash
The data model for a Wgit::Document collection object.
-
.url(url) ⇒ Hash
The data model for a Wgit::Url collection object and for an embedded 'url' inside a Wgit::Document collection object.
Class Method Details
.common_insert_data ⇒ Hash
Common fields when inserting a record into the DB.
37 38 39 40 41 42 |
# File 'lib/wgit/database/model.rb', line 37 def self.common_insert_data { date_added: Wgit::Utils.time_stamp, date_modified: Wgit::Utils.time_stamp } end |
.common_update_data ⇒ Hash
Common fields when updating a record in the DB.
47 48 49 50 51 |
# File 'lib/wgit/database/model.rb', line 47 def self.common_update_data { date_modified: Wgit::Utils.time_stamp } end |
.document(doc) ⇒ Hash
The data model for a Wgit::Document collection object.
25 26 27 28 29 30 31 32 |
# File 'lib/wgit/database/model.rb', line 25 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. Wgit::Utils.remove_non_bson_types(model) end |
.url(url) ⇒ Hash
The data model for a Wgit::Url collection object and for an embedded 'url' inside a Wgit::Document collection object.
13 14 15 16 17 18 19 |
# File 'lib/wgit/database/model.rb', line 13 def self.url(url) raise 'url must respond_to? :to_h' unless url.respond_to?(:to_h) model = url.to_h Wgit::Utils.remove_non_bson_types(model) end |