dynamini 1.8.1 → 1.8.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dynamini/base.rb +9 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cfd29b26d58f37ee6bf6e073e47f229fc8590aa
4
- data.tar.gz: 747642490e8b3ad5318fd66380539fc859ee8d14
3
+ metadata.gz: 13893f0fc6ee9e9871a4627e5becc6d28586faa2
4
+ data.tar.gz: 47ad7abf1223ebc4e7372540a109146adf59644e
5
5
  SHA512:
6
- metadata.gz: 8c8e6686bf978250c59332eb9386fcf08687ffa29283b1b8c546b905b53c207463ac68c011d0e90ddffb7d0044bfdec9642e09a8ee97558d3aa22f8f1edd6c2b
7
- data.tar.gz: ff60046e52efc340c90982c4c7a44bf43ce9a3ada72be5668d1c8431d9046861d4a92e558cc2bfb992221675b7fea1167afc2a270014b8023a27bb204422625a
6
+ metadata.gz: 98a97520da94e1396c0a78c8f0d609d4caadb48ce0adaa2f9c778e1e79b75e73478124aa93e65d9b3f0823472f35ffc31a656a0d81c83f7a1f28f0629f194462
7
+ data.tar.gz: 93936a76f1efe1b2dd22d4f30d05d3cc4019a8bc53e3ca0ee3d59886c2cc58ec5f70d53a3e78633d5e88b9815f664d6595917be2a413ee2739d15c6359f9d38a
@@ -430,9 +430,7 @@ module Dynamini
430
430
 
431
431
  def method_missing(name, *args, &block)
432
432
  if write_method?(name)
433
- attribute = name[0..-2].to_sym
434
- new_value = args.first
435
- write_attribute(attribute, new_value)
433
+ write_attribute(attribute_name(name), args.first)
436
434
  elsif was_method?(name)
437
435
  __was(name)
438
436
  elsif read_method?(name)
@@ -442,6 +440,10 @@ module Dynamini
442
440
  end
443
441
  end
444
442
 
443
+ def attribute_name(name)
444
+ name[0..-2].to_sym
445
+ end
446
+
445
447
  def read_method?(name)
446
448
  name =~ /^([a-zA-Z][-_\w]*)[^=?]*$/
447
449
  end
@@ -451,7 +453,8 @@ module Dynamini
451
453
  end
452
454
 
453
455
  def was_method?(name)
454
- read_method?(name.to_s) && name.to_s.end_with?('_was')
456
+ method_name = name.to_s
457
+ read_method?(method_name) && method_name.end_with?('_was')
455
458
  end
456
459
 
457
460
  def self.define_handled_getter(column, format_class, options = {})
@@ -476,13 +479,13 @@ module Dynamini
476
479
  @attributes.keys.include?(name) || write_method?(name) || was_method?(name) || super
477
480
  end
478
481
 
479
- def write_attribute(attribute, new_value, record_change = true)
482
+ def write_attribute(attribute, new_value, change = true)
480
483
  old_value = read_attribute(attribute)
481
484
  if (handle = handles[attribute.to_sym]) && !new_value.nil?
482
485
  new_value = attribute_callback(SETTER_PROCS, handle, new_value)
483
486
  end
484
487
  @attributes[attribute] = new_value
485
- record_change(attribute, new_value, old_value) if record_change
488
+ record_change(attribute, new_value, old_value) if change && new_value != old_value
486
489
  end
487
490
 
488
491
  def record_change(attribute, new_value, old_value)
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.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.2.2
157
+ rubygems_version: 2.4.8
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: DynamoDB interface