mongocore 0.1.5.6 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61117ab6407f2697bd0e53ea6f496c83aedc9bb8
4
- data.tar.gz: 83964b5ff5fc6e995c3ee55f09c197be2c6a4ea2
3
+ metadata.gz: f2398fe451c3d58b40b9a635a4e5cd365a702cc3
4
+ data.tar.gz: 2e3f32a1f68b45543e75b5dfd9c607d7c81e682a
5
5
  SHA512:
6
- metadata.gz: 38abb821b9d54b9be87a853eb1b78b450269655e1f5038d212302dc6ba331f5e733162cb9ddd6e4f9a02613f6bb4bafd10d1fa8a284a9f619a47c315b6f0342a
7
- data.tar.gz: 813e69998c70273fd3fdd68a2346392d7c656ca00a4838fe65e13c8ef6d25394867ddb8bb506f3b65918ee495b4d1bc36e030ed91b5f753b87140041b3810f28
6
+ metadata.gz: 33843a29724bfcdb0e2e61a9ec9cf4bfae5df8990c1ab250c7bc1a0f8426e9997b53622476fbe553f7a397df3edd311038c13b6582e304358e952a87336a31c6
7
+ data.tar.gz: 6dfae14f09cf37cc1eafd82fd4920e37c676f3682f1ccf1f6fa9bc2b892c910c4a68a72426b9af13eba9ae383bef63ad52c569084a2e4865f72d5ddcf762ba9f
@@ -92,7 +92,7 @@ module Mongocore
92
92
 
93
93
  # Reload the document from db and update attributes
94
94
  def reload
95
- one.first.tap{|m| attributes = m.attributes}
95
+ one.first.tap{|m| self.attributes = m.attributes}
96
96
  end
97
97
 
98
98
  # Set the timestamps if enabled
@@ -107,7 +107,7 @@ module Mongocore
107
107
 
108
108
  # Collect the attributes, pass tags like defined in your model yml
109
109
  def attributes(*tags)
110
- a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)}; string_id(a)
110
+ a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)}; a
111
111
  end
112
112
 
113
113
  # Set the attributes
@@ -122,7 +122,7 @@ module Mongocore
122
122
 
123
123
  # JSON format
124
124
  def as_json(options = {})
125
- attributes
125
+ string_id(attributes)
126
126
  end
127
127
 
128
128
 
@@ -53,8 +53,10 @@ module Mongocore
53
53
  elsif type == :integer then val.to_i
54
54
  elsif type == :float then val.to_f
55
55
  elsif type == :boolean then val.to_s.to_bool
56
- elsif type == :object_id && !val.is_a?(BSON::ObjectId)
57
- BSON::ObjectId.from_string(val) rescue nil
56
+ elsif type == :object_id
57
+ # Convert string id to BSON::ObjectId
58
+ val.each{|k, v| val[k] = BSON::ObjectId.from_string(v) if v.is_a?(String)} if val.is_a?(Hash)
59
+ BSON::ObjectId.from_string(val) rescue val
58
60
  else
59
61
  val
60
62
  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.6'
10
+ VERSION = '0.1.6'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
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.6'
4
- s.date = '2017-10-20'
3
+ s.version = '0.1.6'
4
+ s.date = '2017-10-21'
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.6
4
+ version: 0.1.6
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-20 00:00:00.000000000 Z
11
+ date: 2017-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo