has_changelogs 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/has_changelogs/version.rb +1 -1
- data/lib/has_changelogs.rb +15 -56
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e243805eb29cad2c09fa3b8a01ca4c6a277a420
|
4
|
+
data.tar.gz: 3f2d35a05a61230371adb75f8f95538f92f6bfd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44d42555b52a03a298f58bfbc99bc32c08d7da18b8bbd3d8ebe53cda207163386dc10b01916c95feae5ec7f9a2bf0fb8a679d331768822ab7cf94bea0e27c496
|
7
|
+
data.tar.gz: 45547aa24392c0e49f28afc2190a86c4113ca29ff75678882d7da338d80661908288b6d9c12b095052caa5b46501e95482ef643b8d15ce897df052f55a33269c
|
data/lib/has_changelogs.rb
CHANGED
@@ -66,19 +66,24 @@ module HasChangelogs
|
|
66
66
|
# the actions
|
67
67
|
|
68
68
|
def record_created
|
69
|
-
log_change(
|
69
|
+
log_change(log_action: 'created')
|
70
70
|
end
|
71
71
|
|
72
72
|
def record_updated
|
73
|
-
log_change(
|
73
|
+
log_change(log_action: 'updated')
|
74
74
|
end
|
75
75
|
|
76
76
|
def record_will_be_destroyed
|
77
|
-
log_change(
|
77
|
+
log_change(log_action: 'destroyed', changed_data: attributes)
|
78
78
|
end
|
79
79
|
|
80
80
|
def log_change(options = {})
|
81
|
-
|
81
|
+
defaults = {
|
82
|
+
log_scope: log_scope,
|
83
|
+
changed_data: log_data,
|
84
|
+
log_origin: log_origin }
|
85
|
+
|
86
|
+
changelog_association.create(defaults.merge options)
|
82
87
|
end
|
83
88
|
|
84
89
|
def log_scope
|
@@ -86,8 +91,11 @@ module HasChangelogs
|
|
86
91
|
end
|
87
92
|
|
88
93
|
def logged_model
|
89
|
-
has_changelog_options[:at].present?
|
90
|
-
send(has_changelog_options[:at])
|
94
|
+
if has_changelog_options[:at].present?
|
95
|
+
send(has_changelog_options[:at])
|
96
|
+
else
|
97
|
+
self
|
98
|
+
end
|
91
99
|
end
|
92
100
|
|
93
101
|
def log_origin
|
@@ -109,58 +117,9 @@ module HasChangelogs
|
|
109
117
|
end
|
110
118
|
|
111
119
|
def raw_changed_data(options = {})
|
112
|
-
options[:change_data] ||
|
120
|
+
options[:change_data] || changes || {}
|
113
121
|
end
|
114
122
|
|
115
|
-
# def epic_hero!(options = {})
|
116
|
-
# options[:epic_hero]
|
117
|
-
# end
|
118
|
-
|
119
|
-
# def epic_action!(options = {})
|
120
|
-
# options[:epic_action] || "updated"
|
121
|
-
# end
|
122
|
-
|
123
|
-
# def epic_action_by_admin!(options = {})
|
124
|
-
# !!options[:epic_action_by_admin]
|
125
|
-
# end
|
126
|
-
|
127
|
-
# def log_item(options = {})
|
128
|
-
# options[:log_item] || self
|
129
|
-
# end
|
130
|
-
|
131
|
-
# def epic_item_nickname!(options = {})
|
132
|
-
# options[:log_item_nickname]
|
133
|
-
# end
|
134
|
-
|
135
|
-
# def epic_item_owner!(options = {})
|
136
|
-
# options[:log_item_owner]
|
137
|
-
# end
|
138
|
-
|
139
|
-
|
140
|
-
# def epic_treasure!(options = {})
|
141
|
-
# options[:epic_treasure]
|
142
|
-
# end
|
143
|
-
# def epic_treasure_nickname!(options = {})
|
144
|
-
# options[:epic_treasure_nickname]
|
145
|
-
# end
|
146
|
-
# def epic_treasureguard!(options = {})
|
147
|
-
# options[:epic_treasureguard]
|
148
|
-
# end
|
149
|
-
|
150
|
-
# def epic_change_data!(options = {})
|
151
|
-
# raw_change_data.to_json
|
152
|
-
# end
|
153
|
-
|
154
|
-
# def epic_change_attributes!(options = {})
|
155
|
-
# options[:epic_change_attributes] || raw_change_data(options).keys.join(",")
|
156
|
-
# end
|
157
|
-
|
158
|
-
# private
|
159
|
-
|
160
|
-
# def raw_change_data(options = {})
|
161
|
-
# options[:epic_change_data] || self.changes || {}
|
162
|
-
# end
|
163
|
-
|
164
123
|
end
|
165
124
|
|
166
125
|
def self.included(receiver)
|