loggable_activity 0.1.39 → 0.1.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +1 -0
- data/.nojekyll +1 -0
- data/.rubocop.yml +1 -1
- data/doc/.nojekyll +1 -0
- data/doc/CHANGELOG_md.html +125 -0
- data/doc/CODE_OF_CONDUCT_md.html +220 -0
- data/doc/CONSIDERTIONS_md.html +227 -0
- data/doc/CreateLoggableActivities.html +144 -0
- data/doc/CreateLoggableEncryptionKeys.html +140 -0
- data/doc/CreateLoggablePayloads.html +144 -0
- data/doc/GETTING-STARTED_md.html +186 -0
- data/doc/Gemfile.html +104 -0
- data/doc/Gemfile_lock.html +152 -0
- data/doc/LICENSE_txt.html +104 -0
- data/doc/LoggableActivity/CurrentUser.html +99 -0
- data/doc/LoggableActivity/Generators/InstallGenerator.html +178 -0
- data/doc/LoggableActivity/Generators.html +91 -0
- data/doc/README_md.html +138 -0
- data/doc/ROADMAP_md.html +151 -0
- data/doc/Rakefile.html +102 -0
- data/doc/bin/setup.html +100 -0
- data/doc/notes/CHEAT_SHEET_md.html +130 -0
- data/doc/sig/loggable_activity_rbs.html +101 -0
- data/docs/LoggableActivity/Activity.html +494 -0
- data/docs/LoggableActivity/Configuration.html +183 -0
- data/docs/LoggableActivity/Encryption.html +220 -0
- data/docs/LoggableActivity/EncryptionError.html +99 -0
- data/docs/LoggableActivity/EncryptionKey.html +327 -0
- data/docs/LoggableActivity/Error.html +97 -0
- data/docs/LoggableActivity/Hooks.html +172 -0
- data/docs/LoggableActivity/Payload.html +159 -0
- data/docs/LoggableActivity/PayloadsBuilder.html +154 -0
- data/docs/LoggableActivity/UpdatePayloadsBuilder.html +199 -0
- data/docs/LoggableActivity.html +100 -0
- data/docs/created.rid +10 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +687 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +91 -0
- data/docs/js/darkfish.js +97 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +184 -0
- data/lib/generators/loggable_activity/install_generator.rb +2 -1
- data/lib/generators/loggable_activity/templates/current_user.rb +1 -1
- data/lib/generators/loggable_activity/templates/loggable_activity.yml +29 -0
- data/lib/loggable_activity/activity.rb +208 -59
- data/lib/loggable_activity/configuration.rb +18 -0
- data/lib/loggable_activity/encryption.rb +20 -1
- data/lib/loggable_activity/encryption_key.rb +81 -14
- data/lib/loggable_activity/hooks.rb +10 -7
- data/lib/loggable_activity/payload.rb +45 -11
- data/lib/loggable_activity/payloads_builder.rb +50 -4
- data/lib/loggable_activity/update_payloads_builder.rb +64 -2
- data/lib/loggable_activity/version.rb +1 -1
- metadata +81 -9
- data/.DS_Store +0 -0
- data/loggable_activity-0.1.32.gem +0 -0
- data/loggable_activity-0.1.33.gem +0 -0
- data/loggable_activity-0.1.34.gem +0 -0
@@ -1,44 +1,111 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This the key used to unlock the data for one payload.
|
4
|
-
# When deleted only the encryption_key field is deleted.
|
5
|
-
|
6
3
|
module LoggableActivity
|
4
|
+
# This class represents the encryption key used to unlock the data for one payload.
|
5
|
+
# When deleted, only the encryption_key field is deleted.
|
7
6
|
class EncryptionKey < ActiveRecord::Base
|
8
7
|
self.table_name = 'loggable_encryption_keys'
|
9
|
-
|
8
|
+
|
9
|
+
# Associations
|
10
10
|
belongs_to :record, polymorphic: true, optional: true
|
11
11
|
belongs_to :parrent_key, class_name: 'LoggableActivity::EncryptionKey', optional: true,
|
12
12
|
foreign_key: 'parrent_key_id'
|
13
13
|
|
14
|
+
# Marks the encryption key as deleted by updating the key to nil.
|
14
15
|
def mark_as_deleted
|
15
16
|
update(key: nil)
|
16
17
|
parrent_key.mark_as_deleted if parrent_key.present?
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
# Returns an encryption key for a record by its type and ID, optionally using a parent key.
|
21
|
+
#
|
22
|
+
# @param record_type [String] The type of the record.
|
23
|
+
# @param record_id [Integer] The ID of the record.
|
24
|
+
# @param parent_key [LoggableActivity::EncryptionKey, nil] The parent encryption key, if any.
|
25
|
+
# @return [LoggableActivity::EncryptionKey] The encryption key for the record.
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# LoggableActivity::EncryptionKey.for_record_by_type_and_id('User', 1)
|
29
|
+
#
|
30
|
+
# Returns:
|
31
|
+
# {
|
32
|
+
# :id => 39,
|
33
|
+
# :parrent_key_id => 38,
|
34
|
+
# :key => "a8f4774e7f42eb253045a4db7de7b79e",
|
35
|
+
# :record_type => "User",
|
36
|
+
# :record_id => 1
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
def self.for_record_by_type_and_id(record_type, record_id, parent_key = nil)
|
40
|
+
encryption_key = find_by(record_type:, record_id:)
|
41
|
+
return encryption_key if encryption_key
|
23
42
|
|
24
|
-
create_encryption_key(record_type, record_id,
|
43
|
+
create_encryption_key(record_type, record_id, parent_key)
|
25
44
|
end
|
26
45
|
|
27
|
-
|
46
|
+
# Returns an encryption key for a record, optionally using a parent key.
|
47
|
+
#
|
48
|
+
# @param record [ActiveRecord::Base] The record for which to get the encryption key.
|
49
|
+
# @param parent_key [LoggableActivity::EncryptionKey, nil] The parent encryption key, if any.
|
50
|
+
# @return [LoggableActivity::EncryptionKey] The encryption key for the record.
|
51
|
+
#
|
52
|
+
# Example:
|
53
|
+
# user = User.find(1)
|
54
|
+
# LoggableActivity::EncryptionKey.for_record(user)
|
55
|
+
#
|
56
|
+
# Returns:
|
57
|
+
# {
|
58
|
+
# :id => 39,
|
59
|
+
# :parrent_key_id => 38,
|
60
|
+
# :key => "a8f4774e7f42eb253045a4db7de7b79e",
|
61
|
+
# :record_type => "User",
|
62
|
+
# :record_id => 1
|
63
|
+
# }
|
64
|
+
#
|
65
|
+
def self.for_record(record, parent_key = nil)
|
28
66
|
encryption_key = find_by(record:)
|
29
67
|
return encryption_key if encryption_key
|
30
68
|
|
31
|
-
create_encryption_key(record.class.name, record.id,
|
69
|
+
create_encryption_key(record.class.name, record.id, parent_key)
|
32
70
|
end
|
33
71
|
|
34
|
-
|
35
|
-
|
36
|
-
|
72
|
+
# Creates an encryption key for a record, optionally using a parent key.
|
73
|
+
#
|
74
|
+
# @param record_type [String] The type of the record.
|
75
|
+
# @param record_id [Integer] The ID of the record.
|
76
|
+
# @param parent_key [LoggableActivity::EncryptionKey, nil] The parent encryption key, if any.
|
77
|
+
# @return [LoggableActivity::EncryptionKey] The created encryption key.
|
78
|
+
#
|
79
|
+
# Example:
|
80
|
+
# LoggableActivity::EncryptionKey.create_encryption_key('User', 1)
|
81
|
+
#
|
82
|
+
# Returns:
|
83
|
+
# {
|
84
|
+
# :id => 39,
|
85
|
+
# :parrent_key_id => 38,
|
86
|
+
# :key => "a8f4774e7f42eb253045a4db7de7b79e",
|
87
|
+
# :record_type => "User",
|
88
|
+
# :record_id => 1
|
89
|
+
# }
|
90
|
+
#
|
91
|
+
def self.create_encryption_key(record_type, record_id, parent_key = nil)
|
92
|
+
if parent_key
|
93
|
+
create(record_type:, record_id:, key: random_key, parent_key_id: parent_key.id)
|
37
94
|
else
|
38
95
|
create(record_type:, record_id:, key: random_key)
|
39
96
|
end
|
40
97
|
end
|
41
98
|
|
99
|
+
# Generates a random encryption key.
|
100
|
+
#
|
101
|
+
# @return [String] The generated encryption key.
|
102
|
+
#
|
103
|
+
# Example:
|
104
|
+
# LoggableActivity::EncryptionKey.random_key
|
105
|
+
#
|
106
|
+
# Returns:
|
107
|
+
# "a8f4774e7f42eb253045a4db7de7b79e"
|
108
|
+
#
|
42
109
|
def self.random_key
|
43
110
|
SecureRandom.hex(16)
|
44
111
|
end
|
@@ -6,17 +6,19 @@ require 'loggable_activity/payloads_builder'
|
|
6
6
|
require 'loggable_activity/update_payloads_builder'
|
7
7
|
|
8
8
|
module LoggableActivity
|
9
|
+
# This module provides hooks for creating activities when included in a model.
|
9
10
|
module Hooks
|
10
11
|
extend ActiveSupport::Concern
|
11
12
|
include LoggableActivity::PayloadsBuilder
|
12
13
|
include LoggableActivity::UpdatePayloadsBuilder
|
13
14
|
|
15
|
+
# The included hook sets up configuration and callback hooks for the model.
|
14
16
|
included do
|
15
17
|
config = LoggableActivity::Configuration.for_class(name)
|
16
|
-
if config.nil?
|
17
|
-
raise "Loggable::Configuration not found for #{name}, Please add it to 'config/loggable_activity.yaml'"
|
18
|
-
end
|
19
18
|
|
19
|
+
raise "Loggable::Configuration not found for #{name}, Please add it to 'config/loggable_activity.yaml'" if config.nil?
|
20
|
+
|
21
|
+
# Initializes attributes based on configuration.
|
20
22
|
self.loggable_attrs = config&.fetch('loggable_attrs', []) || []
|
21
23
|
self.relations = config&.fetch('relations', []) || []
|
22
24
|
self.auto_log = config&.fetch('auto_log', []) || []
|
@@ -26,12 +28,13 @@ module LoggableActivity
|
|
26
28
|
after_create :log_create_activity
|
27
29
|
after_update :log_update_activity
|
28
30
|
before_destroy :log_destroy_activity
|
29
|
-
|
30
|
-
# has_one: encryption_key, as: :encryption_key, class_name: 'LoggableActivity::EncryptionKey'
|
31
31
|
end
|
32
32
|
|
33
|
-
#
|
34
|
-
#
|
33
|
+
# Logs an activity with the specified action, actor, and params.
|
34
|
+
#
|
35
|
+
# @param action [Symbol] The action to log (:create, :update, :destroy, or custom).
|
36
|
+
# @param actor [Object] The actor performing the action.
|
37
|
+
# @param params [Hash] Additional parameters for the activity.
|
35
38
|
def log(action, actor: nil, params: {})
|
36
39
|
@action = action
|
37
40
|
@actor = actor || Thread.current[:current_user]
|
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This is the payload of the log. It contains the encrypted data of one record in the DB.
|
4
|
-
# When the record is deleted, the encryption_key for the payload is deleted.
|
5
|
-
# Payloads comes in different flavors.
|
6
|
-
# The primary_payload is the payload that contains the parrent record.
|
7
|
-
# When fecthing the attrs, they are packed differently depending on the payload_type.
|
8
|
-
|
9
3
|
module LoggableActivity
|
4
|
+
# This class represents a payload in the log, containing encrypted data of one record in the database.
|
5
|
+
# When the record is deleted, the encryption key for the payload is also deleted.
|
6
|
+
# Payloads come in different types, each serving a specific purpose.
|
10
7
|
class Payload < ActiveRecord::Base
|
11
8
|
self.table_name = 'loggable_payloads'
|
12
|
-
belongs_to :record, polymorphic: true, optional: true
|
13
9
|
|
10
|
+
# Associations
|
14
11
|
belongs_to :activity
|
15
12
|
belongs_to :record, polymorphic: true, optional: true
|
13
|
+
|
14
|
+
# Validations
|
16
15
|
validates :encrypted_attrs, presence: true
|
16
|
+
|
17
|
+
# Enumeration for different payload types
|
17
18
|
enum payload_type: {
|
18
19
|
primary_payload: 0,
|
19
20
|
update_payload: 1,
|
@@ -21,6 +22,21 @@ module LoggableActivity
|
|
21
22
|
previous_association: 3
|
22
23
|
}
|
23
24
|
|
25
|
+
# Returns the decrypted attributes of the payload based on its type.
|
26
|
+
#
|
27
|
+
# @return [Hash] The decrypted attributes.
|
28
|
+
#
|
29
|
+
# Example:
|
30
|
+
# payload.attrs
|
31
|
+
#
|
32
|
+
# Returns:
|
33
|
+
# {
|
34
|
+
# "street" => "Machu Picchu",
|
35
|
+
# "city" => "Aguas Calientes",
|
36
|
+
# "country" => "Peru",
|
37
|
+
# "postal_code" => "08680"
|
38
|
+
# }
|
39
|
+
#
|
24
40
|
def attrs
|
25
41
|
return deleted_attrs if record.nil?
|
26
42
|
|
@@ -29,27 +45,38 @@ module LoggableActivity
|
|
29
45
|
decrypted_attrs
|
30
46
|
when 'update_payload'
|
31
47
|
decrypted_update_attrs
|
32
|
-
# when 'destroy_payload'
|
33
|
-
# destroy_payload_attrs
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
51
|
+
private
|
52
|
+
|
53
|
+
# Retrieves the encryption key for the payload.
|
54
|
+
#
|
55
|
+
# @return [String, nil] The encryption key.
|
37
56
|
def payload_encryption_key
|
38
57
|
@payload_encryption_key ||= LoggableActivity::EncryptionKey.for_record(record)&.key
|
39
58
|
end
|
40
59
|
|
41
|
-
|
42
|
-
|
60
|
+
# Helper method to handle deleted attributes.
|
61
|
+
#
|
62
|
+
# @return [Hash] The hash with deleted attributes.
|
43
63
|
def deleted_attrs
|
44
64
|
encrypted_attrs.transform_values! { I18n.t('loggable.activity.deleted') }
|
45
65
|
end
|
46
66
|
|
67
|
+
# Decrypts the 'from' and 'to' attributes in the update payload.
|
68
|
+
#
|
69
|
+
# @return [Array<Hash>] The array of decrypted changes.
|
47
70
|
def decrypted_update_attrs
|
48
71
|
encrypted_attrs['changes'].map do |change|
|
49
72
|
decrypted_from_to_attr(change)
|
50
73
|
end
|
51
74
|
end
|
52
75
|
|
76
|
+
# Decrypts 'from' and 'to' attributes.
|
77
|
+
#
|
78
|
+
# @param change [Hash] The change hash containing 'from' and 'to' values.
|
79
|
+
# @return [Hash] The decrypted 'from' and 'to' values.
|
53
80
|
def decrypted_from_to_attr(change)
|
54
81
|
change.to_h do |key, value|
|
55
82
|
from = decrypt_attr(value['from'])
|
@@ -58,12 +85,19 @@ module LoggableActivity
|
|
58
85
|
end
|
59
86
|
end
|
60
87
|
|
88
|
+
# Decrypts all attributes.
|
89
|
+
#
|
90
|
+
# @return [Hash] The decrypted attributes.
|
61
91
|
def decrypted_attrs
|
62
92
|
encrypted_attrs.each do |key, value|
|
63
93
|
encrypted_attrs[key] = decrypt_attr(value)
|
64
94
|
end
|
65
95
|
end
|
66
96
|
|
97
|
+
# Decrypts a single attribute.
|
98
|
+
#
|
99
|
+
# @param value [String] The encrypted value to decrypt.
|
100
|
+
# @return [String] The decrypted value.
|
67
101
|
def decrypt_attr(value)
|
68
102
|
LoggableActivity::Encryption.decrypt(value, payload_encryption_key)
|
69
103
|
end
|
@@ -1,9 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This is a factory for building payloads.
|
4
|
-
|
5
3
|
module LoggableActivity
|
4
|
+
# This module is responsible for building payloads used in loggable activities.
|
6
5
|
module PayloadsBuilder
|
6
|
+
# Builds payloads for the loggable activity.
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
# build_payloads
|
10
|
+
#
|
11
|
+
# Returns:
|
12
|
+
# #<LoggableActivity::Payload:0x0000000109658718> {
|
13
|
+
# :id => 129,
|
14
|
+
# :record_type => "Demo::Club",
|
15
|
+
# :record_id => 4,
|
16
|
+
# :encrypted_attrs => {
|
17
|
+
# "name" => "z/jigjcm3Fb89L7QT8XiNhvVgjtRXKkmg/xohR6wIc0=\n"
|
18
|
+
# },
|
19
|
+
# :payload_type => "current_association",
|
20
|
+
# :data_owner => nil,
|
21
|
+
# :activity_id => 50,
|
22
|
+
# :created_at => Wed, 14 Feb 2024 13:21:13.964339000 UTC +00:00,
|
23
|
+
# :updated_at => Wed, 14 Feb 2024 13:21:13.964339000 UTC +00:00
|
24
|
+
# }
|
25
|
+
#
|
7
26
|
def build_payloads
|
8
27
|
build_primary_payload
|
9
28
|
self.class.relations.each do |relation_config|
|
@@ -12,6 +31,9 @@ module LoggableActivity
|
|
12
31
|
@payloads
|
13
32
|
end
|
14
33
|
|
34
|
+
private
|
35
|
+
|
36
|
+
# Builds the primary payload.
|
15
37
|
def build_primary_payload
|
16
38
|
encrypted_attrs = encrypt_attrs(attributes, self.class.loggable_attrs, primary_encryption_key)
|
17
39
|
@payloads << LoggableActivity::Payload.new(
|
@@ -22,6 +44,7 @@ module LoggableActivity
|
|
22
44
|
)
|
23
45
|
end
|
24
46
|
|
47
|
+
# Builds the payload for destroyed records.
|
25
48
|
def build_destroy_payload
|
26
49
|
encrypted_attrs = encrypt_attrs(attributes, self.class.loggable_attrs, primary_encryption_key)
|
27
50
|
encrypted_attrs.transform_values! { '*** DELETED ***' }
|
@@ -33,6 +56,9 @@ module LoggableActivity
|
|
33
56
|
)
|
34
57
|
end
|
35
58
|
|
59
|
+
# Builds payloads for related records.
|
60
|
+
#
|
61
|
+
# @param relation_config [Hash] The configuration of the relation.
|
36
62
|
def build_relation_payload(relation_config)
|
37
63
|
relation_config.each_key do |key|
|
38
64
|
case key
|
@@ -44,8 +70,12 @@ module LoggableActivity
|
|
44
70
|
end
|
45
71
|
end
|
46
72
|
|
47
|
-
|
48
|
-
|
73
|
+
# Builds the payload for a specific relation.
|
74
|
+
#
|
75
|
+
# @param relation_config [Hash] The configuration of the relation.
|
76
|
+
# @param relation_type [String] The type of the relation.
|
77
|
+
def build_payload(relation_config, relation_type)
|
78
|
+
associated_record = send(relation_config[relation_type])
|
49
79
|
return nil if associated_record.nil?
|
50
80
|
|
51
81
|
associated_loggable_attrs = relation_config['loggable_attrs']
|
@@ -67,6 +97,11 @@ module LoggableActivity
|
|
67
97
|
)
|
68
98
|
end
|
69
99
|
|
100
|
+
# Retrieves the encryption key for the associated record.
|
101
|
+
#
|
102
|
+
# @param associated_record [ActiveRecord::Base] The associated record.
|
103
|
+
# @param data_owner [Boolean] Whether the associated record is the owner of the data.
|
104
|
+
# @return [LoggableActivity::EncryptionKey] The encryption key for the associated record.
|
70
105
|
def associated_record_encryption_key(associated_record, data_owner)
|
71
106
|
if data_owner
|
72
107
|
LoggableActivity::EncryptionKey.for_record(associated_record, LoggableActivity::EncryptionKey.for_record(self))
|
@@ -75,11 +110,22 @@ module LoggableActivity
|
|
75
110
|
end
|
76
111
|
end
|
77
112
|
|
113
|
+
# Encrypts attributes.
|
114
|
+
#
|
115
|
+
# @param attrs [Hash] The attributes to be encrypted.
|
116
|
+
# @param loggable_attrs [Array<String>] The loggable attributes.
|
117
|
+
# @param encryption_key [String] The encryption key.
|
118
|
+
# @return [Hash] The encrypted attributes.
|
78
119
|
def encrypt_attrs(attrs, loggable_attrs, encryption_key)
|
79
120
|
attrs = attrs.slice(*loggable_attrs)
|
80
121
|
encrypt_attr(attrs, encryption_key)
|
81
122
|
end
|
82
123
|
|
124
|
+
# Encrypts a single attribute.
|
125
|
+
#
|
126
|
+
# @param attrs [Hash] The attributes to be encrypted.
|
127
|
+
# @param encryption_key [String] The encryption key.
|
128
|
+
# @return [Hash] The encrypted attributes.
|
83
129
|
def encrypt_attr(attrs, encryption_key)
|
84
130
|
attrs.each do |key, value|
|
85
131
|
attrs[key] = LoggableActivity::Encryption.encrypt(value, encryption_key)
|
@@ -1,9 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This is a factory for building update payloads
|
4
|
-
|
5
3
|
module LoggableActivity
|
4
|
+
# This module is responsible for building update payloads used in loggable activities.
|
6
5
|
module UpdatePayloadsBuilder
|
6
|
+
# Builds payloads for an activity update event.
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
# build_update_payloads
|
10
|
+
#
|
11
|
+
# Returns:
|
12
|
+
# [
|
13
|
+
# [0] #<LoggableActivity::Payload:0x00000001047d31d8> {
|
14
|
+
# :id => nil,
|
15
|
+
# :record_type => "Demo::Club",
|
16
|
+
# :record_id => 7,
|
17
|
+
# :encrypted_attrs => {
|
18
|
+
# "changes" => [
|
19
|
+
# [0] {
|
20
|
+
# "name" => {
|
21
|
+
# "from" => "+aQznZK64KLQ8wsyZlSOGQbqm+J8gDX93rNFeF+wY68=\n",
|
22
|
+
# "to" => "OdS834ZDS06+AYxmz4cUjhtgk7Jc8NoOVAAqR81Is7w=\n"
|
23
|
+
# }
|
24
|
+
# }
|
25
|
+
# ]
|
26
|
+
# },
|
27
|
+
# :payload_type => "update_payload",
|
28
|
+
# :data_owner => false,
|
29
|
+
# :activity_id => nil,
|
30
|
+
# :created_at => nil,
|
31
|
+
# :updated_at => nil
|
32
|
+
# },
|
33
|
+
# [1] #<LoggableActivity::Payload:0x0000000107847f80> {
|
34
|
+
# :id => nil,
|
35
|
+
# :record_type => "Demo::Address",
|
36
|
+
# :record_id => 7,
|
37
|
+
# :encrypted_attrs => {
|
38
|
+
# "street" => "W7cmT22Bb5TKVmtxTYJt1w==\n",
|
39
|
+
# "city" => "AAwdTI7Xo86cMbFBAMsMIw==\n",
|
40
|
+
# "country" => "7gu5wdu6O9tD7Q7+EDOqAg==\n",
|
41
|
+
# "postal_code" => "ljjfT6MXGNK33/PUyi6Nmw==\n"
|
42
|
+
# },
|
43
|
+
# :payload_type => "previous_association",
|
44
|
+
# :data_owner => false,
|
45
|
+
# :activity_id => nil,
|
46
|
+
# :created_at => nil,
|
47
|
+
# :updated_at => nil
|
48
|
+
# },
|
49
|
+
# [2] #<LoggableActivity::Payload:0x0000000107802a98> {
|
50
|
+
# :id => nil,
|
51
|
+
# :record_type => "Demo::Address",
|
52
|
+
# :record_id => 8,
|
53
|
+
# :encrypted_attrs => {
|
54
|
+
# "street" => "CuULVgIEgrOcWBxegKEvSg==\n",
|
55
|
+
# "city" => "QbvodOYMvNFpkvsCprqGqg==\n",
|
56
|
+
# "country" => "/N03d1OL3TY+aaiPUQ5N1A==\n",
|
57
|
+
# "postal_code" => "ZZu3S5tnaTeq+wBu0dPKBw==\n"
|
58
|
+
# },
|
59
|
+
# :payload_type => "current_association",
|
60
|
+
# :data_owner => false,
|
61
|
+
# :activity_id => nil,
|
62
|
+
# :created_at => nil,
|
63
|
+
# :updated_at => nil
|
64
|
+
# }
|
65
|
+
# ]
|
66
|
+
#
|
7
67
|
def build_update_payloads
|
8
68
|
@update_payloads = []
|
9
69
|
|
@@ -16,6 +76,8 @@ module LoggableActivity
|
|
16
76
|
@update_payloads
|
17
77
|
end
|
18
78
|
|
79
|
+
private
|
80
|
+
|
19
81
|
def primary_update_attrs
|
20
82
|
previous_values = saved_changes.transform_values(&:first)
|
21
83
|
current_values = saved_changes.transform_values(&:last)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggable_activity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Max \nGroenlund"
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -37,7 +37,8 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
-
- ".
|
40
|
+
- ".document"
|
41
|
+
- ".nojekyll"
|
41
42
|
- ".rspec"
|
42
43
|
- ".rspec_status"
|
43
44
|
- ".rubocop.yml"
|
@@ -49,6 +50,81 @@ files:
|
|
49
50
|
- README.md
|
50
51
|
- ROADMAP.md
|
51
52
|
- Rakefile
|
53
|
+
- doc/.nojekyll
|
54
|
+
- doc/CHANGELOG_md.html
|
55
|
+
- doc/CODE_OF_CONDUCT_md.html
|
56
|
+
- doc/CONSIDERTIONS_md.html
|
57
|
+
- doc/CreateLoggableActivities.html
|
58
|
+
- doc/CreateLoggableEncryptionKeys.html
|
59
|
+
- doc/CreateLoggablePayloads.html
|
60
|
+
- doc/GETTING-STARTED_md.html
|
61
|
+
- doc/Gemfile.html
|
62
|
+
- doc/Gemfile_lock.html
|
63
|
+
- doc/LICENSE_txt.html
|
64
|
+
- doc/LoggableActivity/CurrentUser.html
|
65
|
+
- doc/LoggableActivity/Generators.html
|
66
|
+
- doc/LoggableActivity/Generators/InstallGenerator.html
|
67
|
+
- doc/README_md.html
|
68
|
+
- doc/ROADMAP_md.html
|
69
|
+
- doc/Rakefile.html
|
70
|
+
- doc/bin/setup.html
|
71
|
+
- doc/notes/CHEAT_SHEET_md.html
|
72
|
+
- doc/sig/loggable_activity_rbs.html
|
73
|
+
- docs/LoggableActivity.html
|
74
|
+
- docs/LoggableActivity/Activity.html
|
75
|
+
- docs/LoggableActivity/Configuration.html
|
76
|
+
- docs/LoggableActivity/Encryption.html
|
77
|
+
- docs/LoggableActivity/EncryptionError.html
|
78
|
+
- docs/LoggableActivity/EncryptionKey.html
|
79
|
+
- docs/LoggableActivity/Error.html
|
80
|
+
- docs/LoggableActivity/Hooks.html
|
81
|
+
- docs/LoggableActivity/Payload.html
|
82
|
+
- docs/LoggableActivity/PayloadsBuilder.html
|
83
|
+
- docs/LoggableActivity/UpdatePayloadsBuilder.html
|
84
|
+
- docs/created.rid
|
85
|
+
- docs/css/fonts.css
|
86
|
+
- docs/css/rdoc.css
|
87
|
+
- docs/fonts/Lato-Light.ttf
|
88
|
+
- docs/fonts/Lato-LightItalic.ttf
|
89
|
+
- docs/fonts/Lato-Regular.ttf
|
90
|
+
- docs/fonts/Lato-RegularItalic.ttf
|
91
|
+
- docs/fonts/SourceCodePro-Bold.ttf
|
92
|
+
- docs/fonts/SourceCodePro-Regular.ttf
|
93
|
+
- docs/images/add.png
|
94
|
+
- docs/images/arrow_up.png
|
95
|
+
- docs/images/brick.png
|
96
|
+
- docs/images/brick_link.png
|
97
|
+
- docs/images/bug.png
|
98
|
+
- docs/images/bullet_black.png
|
99
|
+
- docs/images/bullet_toggle_minus.png
|
100
|
+
- docs/images/bullet_toggle_plus.png
|
101
|
+
- docs/images/date.png
|
102
|
+
- docs/images/delete.png
|
103
|
+
- docs/images/find.png
|
104
|
+
- docs/images/loadingAnimation.gif
|
105
|
+
- docs/images/macFFBgHack.png
|
106
|
+
- docs/images/package.png
|
107
|
+
- docs/images/page_green.png
|
108
|
+
- docs/images/page_white_text.png
|
109
|
+
- docs/images/page_white_width.png
|
110
|
+
- docs/images/plugin.png
|
111
|
+
- docs/images/ruby.png
|
112
|
+
- docs/images/tag_blue.png
|
113
|
+
- docs/images/tag_green.png
|
114
|
+
- docs/images/transparent.png
|
115
|
+
- docs/images/wrench.png
|
116
|
+
- docs/images/wrench_orange.png
|
117
|
+
- docs/images/zoom.png
|
118
|
+
- docs/index.html
|
119
|
+
- docs/js/darkfish.js
|
120
|
+
- docs/js/navigation.js
|
121
|
+
- docs/js/navigation.js.gz
|
122
|
+
- docs/js/search.js
|
123
|
+
- docs/js/search_index.js
|
124
|
+
- docs/js/search_index.js.gz
|
125
|
+
- docs/js/searcher.js
|
126
|
+
- docs/js/searcher.js.gz
|
127
|
+
- docs/table_of_contents.html
|
52
128
|
- lib/.DS_Store
|
53
129
|
- lib/generators/.DS_Store
|
54
130
|
- lib/generators/loggable_activity/.DS_Store
|
@@ -59,6 +135,7 @@ files:
|
|
59
135
|
- lib/generators/loggable_activity/templates/create_loggable_payloads.rb
|
60
136
|
- lib/generators/loggable_activity/templates/current_user.rb
|
61
137
|
- lib/generators/loggable_activity/templates/loggable_activity.en.yml
|
138
|
+
- lib/generators/loggable_activity/templates/loggable_activity.yml
|
62
139
|
- lib/loggable_activity.rb
|
63
140
|
- lib/loggable_activity/.DS_Store
|
64
141
|
- lib/loggable_activity/activity.rb
|
@@ -70,18 +147,13 @@ files:
|
|
70
147
|
- lib/loggable_activity/payloads_builder.rb
|
71
148
|
- lib/loggable_activity/update_payloads_builder.rb
|
72
149
|
- lib/loggable_activity/version.rb
|
73
|
-
- loggable_activity-0.1.32.gem
|
74
|
-
- loggable_activity-0.1.33.gem
|
75
|
-
- loggable_activity-0.1.34.gem
|
76
150
|
- pkg/loggable_activity-0.1.35.gem
|
77
151
|
- sig/loggable_activity.rbs
|
78
152
|
homepage: https://loggableactivity-efe7b931c886.herokuapp.com/
|
79
153
|
licenses:
|
80
154
|
- MIT
|
81
155
|
metadata:
|
82
|
-
|
83
|
-
source_code_uri: https://github.com/maxgronlund/LoggableActivity
|
84
|
-
changelog_uri: https://github.com/maxgronlund/LoggableActivity/CHANGELOG.md
|
156
|
+
documentation_uri: https://maxgronlund.github.io/LoggableActivity/
|
85
157
|
rubygems_mfa_required: 'true'
|
86
158
|
post_install_message:
|
87
159
|
rdoc_options: []
|
data/.DS_Store
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|