superstore 1.0.3 → 1.0.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: 84669dc1d087ef650432331ba37250ac34d475da
4
- data.tar.gz: 4b9cbfdf901f62b442001cf2d255056b836fc6d5
3
+ metadata.gz: cd5cf2fdffdd1441b0a0663f90ef27127795a75e
4
+ data.tar.gz: da3161e0e1f07c0fd2cb2f0f8378bc2c3e3fa679
5
5
  SHA512:
6
- metadata.gz: 0486ef130ad6e9b9687a95ff025232247768d07e218c653ea37a159b3cbfab3a8a4994cc88f6541ed573aaedb9a8119ad49106ae0462726c28af69cbdbfd7f9d
7
- data.tar.gz: 400d2752bff7dc31c12dbfbbca412563b79e8853e7f305d4230856c57e15e2a00b366a38f6658029779f82c03f7b58746e7cee887a58b9b3f621aa6ebcb0258e
6
+ metadata.gz: 9eca1be4674e7b6ed593986499bf5daaed8f574794a6488de55a9b7c141c7da3ef50a5ca3d7dad0e6a29717e9b4c93cd0337c437409b44cffa98987c8c9533fc
7
+ data.tar.gz: 6eac3d6075b98f8658030c6d1d3aceeeb1e0b3e308ce88af92a9c20580a7d062d388fd849afff147cd134c64da9fb5bd70dd9048213a8f012c7f81f66225dcfb
@@ -21,6 +21,12 @@ module Superstore
21
21
  end
22
22
  end
23
23
 
24
+ def unapplied_changes
25
+ result = {}
26
+ changed_attributes.each_key { |attr| result[attr] = read_attribute(attr) }
27
+ result
28
+ end
29
+
24
30
  def write_attribute(name, value)
25
31
  name = name.to_s
26
32
  old = read_attribute(name)
@@ -146,8 +146,7 @@ module Superstore
146
146
  end
147
147
 
148
148
  def write(method)
149
- changed_attributes = Hash[changed.map { |attr| [attr, read_attribute(attr)] }]
150
- self.class.send(method, id, changed_attributes)
149
+ self.class.send(method, id, unapplied_changes)
151
150
  end
152
151
  end
153
152
  end
data/superstore.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'superstore'
5
- s.version = '1.0.3'
5
+ s.version = '1.0.4'
6
6
  s.description = 'ActiveModel for many attributes'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
  s.authors = ["Michael Koziarski", "gotime"]
@@ -51,6 +51,17 @@ class Superstore::AttributeMethods::DirtyTest < Superstore::TestCase
51
51
  assert record.changed?
52
52
  end
53
53
 
54
+ test 'unapplied_changes' do
55
+ record = temp_object do
56
+ float :price
57
+ string :color
58
+ end.create(price: 5.01, color: 'green')
59
+
60
+ record.color = 'blue'
61
+
62
+ assert_equal({'color' => 'blue'}, record.unapplied_changes)
63
+ end
64
+
54
65
  test 'write_attribute' do
55
66
  object = temp_object do
56
67
  string :name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Koziarski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-18 00:00:00.000000000 Z
12
+ date: 2014-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel