mongocore 0.1.4 → 0.1.4.1

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: b5142d4d77d8f53bfa680bddfc7d4c30f43a6781
4
- data.tar.gz: fe5706822aceef5d22b4aacafb4e0b93a5694a7f
3
+ metadata.gz: 82ab8bff97378c5d4201d927c111a9975d3a1b66
4
+ data.tar.gz: a4c9fb66a260bc63c7bebc73a2420e268efbfa79
5
5
  SHA512:
6
- metadata.gz: edd90f1124dd3b80489e87e578e2c289ffcd2f641c7a3d326201990fa3b3b9b159823ff5cd39e6a1e53e1a68fbf059e22d4e27a1ccfbfb0903cd6de776502013
7
- data.tar.gz: 4d2e8e4e1f1b2179fd748cc33a3c2ca12f034bb3bc02d836d4b48ccecd2af4467de711587cd597acbc3c11f4516f56768f92c22a9a48639fed2a64817e8ea0dc
6
+ metadata.gz: 8b946978a281316973d65c9f93d814a8c8b44eb84f11c71839bc994b77619632a3486750b99517408159080ab3616dd323a7db4540d1cc8c4274fb51250a15de
7
+ data.tar.gz: b5f1b9c1eace40133164715217fec0ebc14a977b9be9a38b90b8044297a3c12d4581750fdc7c474897e6871db097e1bca5427a3fac49eacf106347775cba5c3b
@@ -49,7 +49,6 @@ module Mongocore
49
49
  # Pass in attributes you want to set: Model.new(:duration => 60)
50
50
  # Defaults are filled in automatically.
51
51
  #
52
-
53
52
  def initialize(a = {})
54
53
  a = a.deep_symbolize_keys
55
54
 
@@ -117,7 +116,7 @@ module Mongocore
117
116
 
118
117
  # Collect the attributes, pass tags like defined in your model yml
119
118
  def attributes(*tags)
120
- a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)}; a
119
+ a = {}; self.class.schema.attributes(tags.map(&:to_s)).each{|k| a[k] = read!(k)}; string_id(a)
121
120
  end
122
121
 
123
122
  # Set the attributes
@@ -130,9 +129,9 @@ module Mongocore
130
129
  changes.any?
131
130
  end
132
131
 
133
- # JSON format, pass tags as symbols: to_json(:badge, :gun)
134
- def to_json(*args)
135
- a = attributes(*args); a.delete(:_id); {:id => id}.merge(a).to_json
132
+ # JSON format
133
+ def as_json(options = {})
134
+ attributes
136
135
  end
137
136
 
138
137
 
@@ -231,6 +230,11 @@ module Mongocore
231
230
  @_id ? @_id.to_s : nil
232
231
  end
233
232
 
233
+ # Replace _id with id, takes a hash
234
+ def string_id(a)
235
+ a.delete(:_id); {:id => id}.merge(a)
236
+ end
237
+
234
238
  end
235
239
 
236
240
 
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.4'
4
- s.date = '2017-10-15'
3
+ s.version = '0.1.4.1'
4
+ s.date = '2017-10-16'
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.4
4
+ version: 0.1.4.1
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-15 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo