nano-store 0.4.1 → 0.4.2

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.
@@ -22,10 +22,11 @@ module NanoStore
22
22
  module ModelClassMethods
23
23
  # initialize a new object
24
24
  def new(data={})
25
- extra_keys = (data.keys - self.attributes)
26
- if extra_keys.size > 0
27
- raise NanoStoreError, "fields #{extra_keys.join(', ')} is not a defined fields"
28
- end
25
+ data.keys.each { |k|
26
+ unless self.attributes.member? k.to_sym
27
+ raise NanoStoreError, "'#{k}' is not a defined attribute for this model"
28
+ end
29
+ }
29
30
 
30
31
  object = self.nanoObjectWithDictionary(data)
31
32
  object
@@ -88,4 +89,4 @@ module NanoStore
88
89
  extend ModelClassMethods
89
90
  extend ::NanoStore::FinderMethods
90
91
  end
91
- end
92
+ end
@@ -1,3 +1,3 @@
1
1
  module NanoStore
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -107,4 +107,22 @@ describe "StoreExtension" do
107
107
  Animal.count.should == 0
108
108
  end
109
109
 
110
+ it "should save in batch" do
111
+ store = NanoStore.shared_store = NanoStore.store
112
+
113
+ store.save_interval = 1000
114
+
115
+ Animal.count.should == 0
116
+ obj1 = Animal.new
117
+ obj1.name = "Cat"
118
+ store << obj1
119
+
120
+ obj2 = Animal.new
121
+ obj2.name = "Dog"
122
+ store << obj2
123
+ store.save
124
+
125
+ Animal.count.should == 2
126
+ end
127
+
110
128
  end
data/vendor/Podfile.lock CHANGED
@@ -8,4 +8,4 @@ DEPENDENCIES:
8
8
  SPEC CHECKSUMS:
9
9
  NanoStore: 440272829dfe13db7f1c68de74fc3562475463fe
10
10
 
11
- COCOAPODS: 0.15.1
11
+ COCOAPODS: 0.15.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nano-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-07 00:00:00.000000000 Z
12
+ date: 2012-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bubble-wrap
@@ -188,18 +188,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
188
  - - ! '>='
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
- segments:
192
- - 0
193
- hash: -557575853161670101
194
191
  required_rubygems_version: !ruby/object:Gem::Requirement
195
192
  none: false
196
193
  requirements:
197
194
  - - ! '>='
198
195
  - !ruby/object:Gem::Version
199
196
  version: '0'
200
- segments:
201
- - 0
202
- hash: -557575853161670101
203
197
  requirements: []
204
198
  rubyforge_project:
205
199
  rubygems_version: 1.8.24