recorder 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/recorder/changeset.rb +29 -0
- data/lib/recorder/draper/decorator_concern.rb +13 -2
- data/lib/recorder/version.rb +1 -1
- data/lib/recorder.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b0b14fc30386cd30b206daa0cb70ca0c6e41c3
|
4
|
+
data.tar.gz: edaec63b8d20474305a7bc0c5ab5a8af1bcfd674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44c6ae6cd9601f2d8bb7705c9a3e6c01090c574c8bf3f139b72aee8d55e2e12a5553c3824f461a22bbc9d729a7aba1cd0bebfc13ab148a4700b43fc69811e60
|
7
|
+
data.tar.gz: 0e1416888ae65f8fadb465577612ba79a90bd603df248091b420afe0d079147913a05967185faf9e5d4decc9988093783d82d5c503abafcda15737440cf66290
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Recorder::Changeset
|
2
|
+
attr_reader :item, :changes
|
3
|
+
|
4
|
+
def initialize(item, changes)
|
5
|
+
@item = item; @changes = changes
|
6
|
+
end
|
7
|
+
|
8
|
+
def attributes
|
9
|
+
self.changes.keys
|
10
|
+
end
|
11
|
+
|
12
|
+
def human_attribute_name(attribute)
|
13
|
+
self.item.class.human_attribute_name(attribute.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
def before(attribute)
|
17
|
+
self.changes[attribute.to_s][0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def after(attribute)
|
21
|
+
self.changes[attribute.to_s][1]
|
22
|
+
end
|
23
|
+
|
24
|
+
# def
|
25
|
+
|
26
|
+
# def item_human_attribute_name(attribute)
|
27
|
+
# self.item.source.class.human_attribute_name(attribute)
|
28
|
+
# end
|
29
|
+
end
|
@@ -5,8 +5,19 @@ module Recorder
|
|
5
5
|
base.decorates_association :item
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
self.item.source.
|
8
|
+
def item_changeset
|
9
|
+
@item_changeset ||= Recorder::Changeset.new(self.item.source, source.data['changes'])
|
10
|
+
end
|
11
|
+
|
12
|
+
def changed_associations
|
13
|
+
source.data['associations'].keys#.map{ |association| self.item_human_attribute_name(association) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def association_changeset(name)
|
17
|
+
association = self.item.send(name)
|
18
|
+
association = association.source if association.decorated?
|
19
|
+
|
20
|
+
Recorder::Changeset.new(association, source.data['associations'].fetch(name.to_s).try(:fetch, 'changes'))
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
data/lib/recorder/version.rb
CHANGED
data/lib/recorder.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Alexandrov
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/generators/recorder/install_generator.rb
|
141
141
|
- lib/generators/recorder/templates/create_recorder_revisions.rb
|
142
142
|
- lib/recorder.rb
|
143
|
+
- lib/recorder/changeset.rb
|
143
144
|
- lib/recorder/draper/decorator_concern.rb
|
144
145
|
- lib/recorder/observer.rb
|
145
146
|
- lib/recorder/rails/controller_concern.rb
|