mongocore 0.1.5.3 → 0.1.5.4

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: c244545f62fec979cdb7c7040f405ddbe99cc76e
4
- data.tar.gz: fb4f8f451c2231baac447819f34d3b0491b38421
3
+ metadata.gz: 528cba77e5787960a365aa15629a703e41fcedd3
4
+ data.tar.gz: 774cb561e0ce794c80a3ff3a03e0cc00c8ec767c
5
5
  SHA512:
6
- metadata.gz: c80c0b596e67f028244c6744fdb6188bb8a6c1d71a9e3d7c35b67517431e1c36b26e39a70ec26ea664ec71c3956e675a571e14d3ae06f3828533c72611ca11dc
7
- data.tar.gz: 27ec9db00a4648be973a0cebdb154155a7fedb2ea32ba225e830b1465e00a9cfd749a3e986e4f4671d1f84155f943ba917c2f98a532b044392d51cb96bdac062
6
+ metadata.gz: 4648a17cbc9670bef907be425fa17a3c50a924cefedf7f35e08364130c0f409c3f130abc39d896a8dfc4091cd3801b75b67e537bf745079888852a15585e2e91
7
+ data.tar.gz: d3a1921104bbbc4f26ab79bbe789105fb878e285e1dbf13cdfcd5a0130320d11ad2dde5b345ae81e0d81abbe1f71cf275cba2543163dfb00206ac11f70c6c251
@@ -46,7 +46,7 @@ module Mongocore
46
46
  q[:_id] = q.delete(:id) if q[:id]
47
47
 
48
48
  # Convert object ID's to BSON::ObjectIds
49
- q.each{|k, v| q[k] = oid(v) if k =~ /_id$/}
49
+ q.each{|k, v| q[k] = @model.schema.convert(k, v) if k =~ /_id$/}
50
50
 
51
51
  q
52
52
  end
@@ -46,17 +46,18 @@ module Mongocore
46
46
  # Convert type if val and schema type is set
47
47
  def convert(key, val)
48
48
  return nil if val.nil?
49
- type = @keys[key][:type].to_sym rescue nil
50
- return val if type.nil?
49
+ type = @keys[key][:type].to_sym rescue :string
51
50
 
52
51
  # Convert to the same type as in the schema
53
- return val.to_i if type == :integer
54
- return val.to_f if type == :float
55
- return !!val if type == :boolean
56
- if type == :object_id and !val.is_a?(BSON::ObjectId)
57
- return BSON::ObjectId.from_string(val) rescue nil
52
+ if type == :string then val.to_s
53
+ elsif type == :integer then val.to_i
54
+ elsif type == :float then val.to_f
55
+ elsif type == :boolean then !!val
56
+ elsif type == :object_id && val.is_a?(String)
57
+ BSON::ObjectId.from_string(val) rescue nil
58
+ else
59
+ val
58
60
  end
59
- val
60
61
  end
61
62
 
62
63
  # # # # # # # # #
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.3'
10
+ VERSION = '0.1.5.4'
11
11
 
12
12
  # # # # # #
13
13
  # Mongocore Ruby Database Driver.
data/mongocore.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mongocore'
3
- s.version = '0.1.5.3'
3
+ s.version = '0.1.5.4'
4
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."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongocore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.3
4
+ version: 0.1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited