dynamini 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamini/base.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cfd29b26d58f37ee6bf6e073e47f229fc8590aa
|
4
|
+
data.tar.gz: 747642490e8b3ad5318fd66380539fc859ee8d14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8e6686bf978250c59332eb9386fcf08687ffa29283b1b8c546b905b53c207463ac68c011d0e90ddffb7d0044bfdec9642e09a8ee97558d3aa22f8f1edd6c2b
|
7
|
+
data.tar.gz: ff60046e52efc340c90982c4c7a44bf43ce9a3ada72be5668d1c8431d9046861d4a92e558cc2bfb992221675b7fea1167afc2a270014b8023a27bb204422625a
|
data/lib/dynamini/base.rb
CHANGED
@@ -433,6 +433,8 @@ module Dynamini
|
|
433
433
|
attribute = name[0..-2].to_sym
|
434
434
|
new_value = args.first
|
435
435
|
write_attribute(attribute, new_value)
|
436
|
+
elsif was_method?(name)
|
437
|
+
__was(name)
|
436
438
|
elsif read_method?(name)
|
437
439
|
read_attribute(name)
|
438
440
|
else
|
@@ -448,6 +450,10 @@ module Dynamini
|
|
448
450
|
name =~ /^([a-zA-Z][-_\w]*)=.*$/
|
449
451
|
end
|
450
452
|
|
453
|
+
def was_method?(name)
|
454
|
+
read_method?(name.to_s) && name.to_s.end_with?('_was')
|
455
|
+
end
|
456
|
+
|
451
457
|
def self.define_handled_getter(column, format_class, options = {})
|
452
458
|
proc = GETTER_PROCS[format_class]
|
453
459
|
fail 'Unsupported data type: ' + format_class.to_s if proc.nil?
|
@@ -467,7 +473,7 @@ module Dynamini
|
|
467
473
|
end
|
468
474
|
|
469
475
|
def respond_to_missing?(name, include_private = false)
|
470
|
-
@attributes.keys.include?(name) || write_method?(name) || super
|
476
|
+
@attributes.keys.include?(name) || write_method?(name) || was_method?(name) || super
|
471
477
|
end
|
472
478
|
|
473
479
|
def write_attribute(attribute, new_value, record_change = true)
|
@@ -497,6 +503,12 @@ module Dynamini
|
|
497
503
|
value.is_a?(Array) ? value.map { |e| callback.call(e) } : callback.call(value)
|
498
504
|
end
|
499
505
|
|
506
|
+
def __was(name)
|
507
|
+
attr_name = name[0..-5].to_sym
|
508
|
+
raise ArgumentError unless (@attributes[attr_name] || handles[attr_name])
|
509
|
+
@changes[attr_name].compact.present? ? @changes[attr_name][0] : read_attribute(attr_name)
|
510
|
+
end
|
511
|
+
|
500
512
|
def handles
|
501
513
|
self.class.handles
|
502
514
|
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.8.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Ward
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2015-12-
|
18
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activemodel
|