active_outbox 0.1.2 → 0.1.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef235321d10ec48e78a45e7b894ef50bffb6e73bf6e7d94971f19ed5f945e137
|
4
|
+
data.tar.gz: df6f204e1644416d5351af321e8f2cd832b0a7fad22e9d38385902f48e1e146b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3322c31bd2dd05f239d5373fb772033583407576b5be4b14b184c5d97abc5ba1dd0aa7516e27b0f11519848d381948c8031c79c0d0916eaadd1566e78709d30
|
7
|
+
data.tar.gz: 803e2a29abded8d24ecd32492c39f19b26103769b47a7952d16114b5073bf5e42711d369e43f8d09e25cd9ce6d446c7492051e661d22f2c24becc66e25e7b66f
|
data/README.md
CHANGED
@@ -37,13 +37,16 @@ gem install active_outbox
|
|
37
37
|
|
38
38
|
## Usage
|
39
39
|
### Setup
|
40
|
-
Create
|
40
|
+
Create the outbox table and model using the provided generator. Any model name can be passed as an argument but if empty it will default to `outboxes` and `Outbox` respectively.
|
41
41
|
```bash
|
42
|
-
rails g active_outbox:
|
42
|
+
rails g active_outbox:model <optional model_name>
|
43
|
+
|
44
|
+
create db/migrate/20231115182800_active_outbox_create_<model_name_>outboxes.rb
|
45
|
+
create app/models/<model_name_>outbox.rb
|
43
46
|
```
|
44
|
-
After
|
47
|
+
After running the migration, create an initializer under `config/initializers/active_outbox.rb` and setup the default outbox class to the new `Outbox` model you just created.
|
45
48
|
```bash
|
46
|
-
rails g active_outbox:
|
49
|
+
rails g active_outbox:install
|
47
50
|
```
|
48
51
|
|
49
52
|
To allow models to store Outbox records on changes, you will have to include the `Outboxable` concern.
|
@@ -71,8 +74,15 @@ By default our Outbox migration has an `aggregate_identifier` field which serves
|
|
71
74
|
```bash
|
72
75
|
rails g active_outbox:model <optional model_name> --uuid
|
73
76
|
```
|
74
|
-
###
|
75
|
-
If more granularity is desired multiple
|
77
|
+
### Modularized Outbox Mappings
|
78
|
+
If more granularity is desired multiple outbox classes can be configured. Using the provided generators we can specify namespaces and the folder structure.
|
79
|
+
```bash
|
80
|
+
rails g active_outbox:model user_access/ --component-path packs/user_access
|
81
|
+
|
82
|
+
create packs/user_access/db/migrate/20231115181205_active_outbox_create_user_access_outboxes.rb
|
83
|
+
create packs/user_access/app/models/user_access/outbox.rb
|
84
|
+
```
|
85
|
+
After creating the needed `Outbox` classes for each module you can specify multiple mappings in the initializer.
|
76
86
|
```ruby
|
77
87
|
# frozen_string_literal: true
|
78
88
|
|
@@ -35,10 +35,13 @@ module ActiveOutbox
|
|
35
35
|
"#{migration_path}/active_outbox_create_#{table_name}.rb",
|
36
36
|
migration_version: migration_version
|
37
37
|
)
|
38
|
+
|
39
|
+
template('model.rb', "#{root_path}/app/models/#{path_name}.rb")
|
38
40
|
end
|
39
41
|
|
40
42
|
def root_path
|
41
|
-
options['component_path']
|
43
|
+
path = options['component_path'].blank? ? '' : "/#{options['component_path']}"
|
44
|
+
"#{Rails.root}#{path}"
|
42
45
|
end
|
43
46
|
|
44
47
|
def migration_version
|
@@ -46,11 +49,25 @@ module ActiveOutbox
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def table_name
|
49
|
-
model_name.
|
52
|
+
*namespace, name = model_name.downcase.split('/')
|
53
|
+
name = name.blank? ? 'outboxes' : "#{name}_outboxes"
|
54
|
+
namespace = namespace.join('_')
|
55
|
+
namespace.blank? ? name : "#{namespace}_#{name}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def path_name
|
59
|
+
name = ''
|
60
|
+
*namespace = model_name.downcase.split('/')
|
61
|
+
if (model_name.include?('/') && model_name.last != '/' && namespace.length > 1) || !model_name.include?('/')
|
62
|
+
name = namespace.pop
|
63
|
+
end
|
64
|
+
name = name.blank? ? 'outbox' : "#{name}_outbox"
|
65
|
+
namespace = namespace.join('/')
|
66
|
+
namespace.blank? ? name : "#{namespace}/#{name}"
|
50
67
|
end
|
51
68
|
|
52
69
|
def aggregate_identifier_type
|
53
|
-
options['uuid'].present? ? ActiveOutbox::AdapterHelper.uuid_type :
|
70
|
+
options['uuid'].present? ? ActiveOutbox::AdapterHelper.uuid_type : ActiveOutbox::AdapterHelper.bigint_type
|
54
71
|
end
|
55
72
|
end
|
56
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_outbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillermo Aguirre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/generators/active_outbox/model/model_generator.rb
|
57
57
|
- lib/generators/active_outbox/templates/initializer.rb
|
58
58
|
- lib/generators/active_outbox/templates/migration.rb
|
59
|
+
- lib/generators/active_outbox/templates/model.rb
|
59
60
|
homepage: https://rubygems.org/gems/active_outbox
|
60
61
|
licenses:
|
61
62
|
- MIT
|