dynamini 1.2.0 → 1.2.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dynamini/base.rb +17 -3
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17933fcac602cd13774496419949da3f0efb191
4
- data.tar.gz: a18646361e33095425e7b44d3a5d5ad0bf8c789c
3
+ metadata.gz: af8e968f7a6e4c42d137bfe5d91b350f46e47051
4
+ data.tar.gz: 81a376d13bf4216d8968d121efae3dadaa94264b
5
5
  SHA512:
6
- metadata.gz: 4457c3c065d4b2c0471cd43fb47afc09a0af5684a7c81f57cf3b26d5e16875738bc4c0e9b53ae8f88703b595983930d591bfaf0e136d1f49da0817cd5a85f20f
7
- data.tar.gz: 8ff5ca270a505f7d0ed21c8e8ca2b453919cde5d3a6117e0e809466c20e24e73fa44912dcb59a9d0e3724783891918937dc506e0c43d9f6a0380df88f9778375
6
+ metadata.gz: 6ff41641895ab60cfd6bca3d0e67a4473d148865f968bbbed873862a0fc64b94d97f45241645d6b8168fdce94932ee9337b3b64a64618a6cbedf909559659a41
7
+ data.tar.gz: 218ef28fd709806d5d3bc43d255f2fb6ef106f15071db9b2ce13e783d0a62290c485dd789ccb58e3ec9d19c1c93c6fd49ef539b9d72347d175673cb29662b991
data/lib/dynamini/base.rb CHANGED
@@ -52,8 +52,8 @@ module Dynamini
52
52
  end
53
53
 
54
54
  def exists?(key)
55
- return true if client.get_item(table_name: table_name, key: {hash_key => key.to_s})
56
- false
55
+ response = client.get_item(table_name: table_name, key: {hash_key => key.to_s})
56
+ response.item.present?
57
57
  end
58
58
 
59
59
  def find_or_new(key)
@@ -100,7 +100,7 @@ module Dynamini
100
100
  @attributes = attributes
101
101
  @changed = Set.new
102
102
  @new_record = new_record
103
- add_changed(attributes)
103
+ add_changed(attributes) if new_record
104
104
  end
105
105
 
106
106
  def assign_attributes(attributes)
@@ -111,6 +111,20 @@ module Dynamini
111
111
  nil
112
112
  end
113
113
 
114
+ def update_attribute(key, value)
115
+ record_change(key, value, @attributes[key])
116
+ @attributes[key] = value
117
+ save!
118
+ end
119
+
120
+ def update_attributes(attributes)
121
+ attributes.each do |key, value|
122
+ record_change(key, read_attribute(key), value)
123
+ end
124
+ @attributes.merge!(attributes)
125
+ save!
126
+ end
127
+
114
128
  def save(options = {})
115
129
  @changed.empty? || valid? && trigger_save(options)
116
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -69,8 +69,8 @@ dependencies:
69
69
  - - ~>
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
- description: Lightweight DynamoDB interface designed as a drop-in replacement for
73
- ActiveRecord.
72
+ description: Lightweight DynamoDB interface gem designed as a drop-in replacement
73
+ for ActiveRecord.
74
74
  email: dev@retailcommon.com
75
75
  executables: []
76
76
  extensions: []