mongocore 0.1.5.2 → 0.1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8406e027e9d11ccad7906264efe1f10de042a595
4
- data.tar.gz: aa82f4b6c183fa2b9e438d345c0729094cc822f5
3
+ metadata.gz: c244545f62fec979cdb7c7040f405ddbe99cc76e
4
+ data.tar.gz: fb4f8f451c2231baac447819f34d3b0491b38421
5
5
  SHA512:
6
- metadata.gz: b27b7636d13fc80b9eea72d25ae6c70147d88171c600e409323ce869de7d092d49cad1c3f1ade2c743cc889bd54780b1282750832591f90fdbab47803ed7abc9
7
- data.tar.gz: c6cc32012de6d4050509a337bc8a997d88f7209321c910ee5d220f264e4c92562f141451586ad8cf7640975fe57e0af62877264072ee10993ae6569c323fb567
6
+ metadata.gz: c80c0b596e67f028244c6744fdb6188bb8a6c1d71a9e3d7c35b67517431e1c36b26e39a70ec26ea664ec71c3956e675a571e14d3ae06f3828533c72611ca11dc
7
+ data.tar.gz: 27ec9db00a4648be973a0cebdb154155a7fedb2ea32ba225e830b1465e00a9cfd749a3e986e4f4671d1f84155f943ba917c2f98a532b044392d51cb96bdac062
@@ -43,26 +43,21 @@ module Mongocore
43
43
 
44
44
  attr_accessor :errors, :changes, :saved
45
45
 
46
-
47
46
  # # # # # # # # # # #
48
47
  # The class initializer, called when you write Model.new
49
48
  # Pass in attributes you want to set: Model.new(:duration => 60)
50
49
  # Defaults are filled in automatically.
51
50
  #
52
51
  def initialize(a = {})
53
- a = a.deep_symbolize_keys
54
-
55
- # The _id has the BSON object, create new unless it exists
56
- a[:_id] ? @saved = true : a[:_id] = BSON::ObjectId.new
57
-
58
- # The errors hash
59
- @errors = Mongocore::Errors.new{|h, k| h[k] = []}
60
52
 
61
53
  # Defaults
62
- self.class.schema.defaults.each{|k, v| write(k, v)}
54
+ self.attributes = self.class.schema.defaults.merge(a)
55
+
56
+ # The _id is a BSON object, create new unless it exists
57
+ @_id ? @saved = true : @_id = BSON::ObjectId.new
63
58
 
64
- # Set the attributes
65
- a.each{|k, v| write(k, v)}
59
+ # The errors hash
60
+ @errors = Hash.new{|h, k| h[k] = []}
66
61
 
67
62
  # The changes hash
68
63
  @changes = Hash.new{|h, k| h[k] = []}
@@ -86,7 +81,7 @@ module Mongocore
86
81
 
87
82
  # Update document in db
88
83
  def update(a = {})
89
- a.each{|k, v| write(k, v)}; filter(:update){single.update(a).ok?}
84
+ self.attributes = a; filter(:update){single.update(a).ok?}
90
85
  end
91
86
 
92
87
  # Delete a document in db
@@ -39,7 +39,6 @@ module Mongocore
39
39
 
40
40
  # Normalize query
41
41
  def normalize(q)
42
-
43
42
  # Support find passing an ID
44
43
  q = {:_id => oid(q)} unless q.is_a?(Hash)
45
44
 
@@ -105,7 +104,6 @@ module Mongocore
105
104
 
106
105
  # Paginate
107
106
  def paginate(o = {})
108
-
109
107
  # Get total count before applying pagination
110
108
  total = fetch(:count)
111
109
 
@@ -112,6 +112,5 @@ module Mongocore
112
112
  @klass.instance_eval t
113
113
  end
114
114
 
115
-
116
115
  end
117
116
  end
data/lib/mongocore.rb CHANGED
@@ -7,7 +7,7 @@ require 'mongo'
7
7
  require 'request_store'
8
8
 
9
9
  module Mongocore
10
- VERSION = '0.1.5.2'
10
+ VERSION = '0.1.5.3'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
@@ -38,7 +38,6 @@ module Mongocore
38
38
  end
39
39
 
40
40
  require_relative 'mongocore/ext'
41
- require_relative 'mongocore/errors'
42
41
  require_relative 'mongocore/document'
43
42
  require_relative 'mongocore/query'
44
43
  require_relative 'mongocore/schema'
data/mongocore.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongocore'
3
- s.version = '0.1.5.2'
4
- s.date = '2017-10-17'
3
+ s.version = '0.1.5.3'
4
+ s.date = '2017-10-18'
5
5
  s.summary = "MongoDB ORM implementation on top of the Ruby MongoDB driver"
6
6
  s.description = "Does validations, associations, scopes, filters, pagination, counter cache, request cache, and nested queries. Using a YAML schema file, which supports default values, data types, and security levels for each key."
7
7
  s.authors = ["Fugroup Limited"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongocore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.2
4
+ version: 0.1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2017-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -86,7 +86,6 @@ files:
86
86
  - lib/mongocore/access.rb
87
87
  - lib/mongocore/cache.rb
88
88
  - lib/mongocore/document.rb
89
- - lib/mongocore/errors.rb
90
89
  - lib/mongocore/ext.rb
91
90
  - lib/mongocore/filters.rb
92
91
  - lib/mongocore/query.rb
@@ -1,5 +0,0 @@
1
- module Mongocore
2
- class Errors < Hash
3
-
4
- end
5
- end