Skip to content

Commit

Permalink
Improve config (#14)
Browse files Browse the repository at this point in the history
* Add dry_configurable to gemspec

* Use dry-configurable, remove custom config setup
  • Loading branch information
guillermoap authored Oct 23, 2023
1 parent 6d4fa02 commit 4ebff3c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ AllCops:
Gemspec/RequireMFA:
Enabled: false

Lint/DuplicateMethods:
Exclude:
- lib/active_outbox/configuration.rb

Metrics/MethodLength:
Max: 12

Expand Down
9 changes: 8 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PATH
remote: .
specs:
active_outbox (0.0.3)
active_outbox (0.0.4)
dry-configurable (~> 1.0)
rails (~> 6.1)

GEM
Expand Down Expand Up @@ -80,6 +81,12 @@ GEM
date (3.3.3)
diff-lcs (1.5.0)
docile (1.4.0)
dry-configurable (1.1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
erubi (1.12.0)
globalid (1.2.1)
activesupport (>= 6.1)
Expand Down
3 changes: 2 additions & 1 deletion active_outbox.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Gem::Specification.new do |spec|
spec.files = Dir['LICENSE.txt', 'README.md', 'lib/**/*', 'lib/active_outbox.rb']
spec.name = 'active_outbox'
spec.summary = 'A Transactional Outbox implementation for ActiveRecord'
spec.version = '0.0.3'
spec.version = '0.0.4'

spec.email = 'guillermoaguirre1@gmail.com'
spec.executables = ['outbox']
spec.homepage = 'https://rubygems.org/gems/active_outbox'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'dry-configurable', '~> 1.0'
spec.add_dependency 'rails', '~> 6.1'
end
9 changes: 8 additions & 1 deletion lib/active_outbox.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# frozen_string_literal: true

require 'active_outbox/adapter_helper'
require 'active_outbox/configuration'
require 'active_outbox/errors'
require 'active_outbox/generators/active_outbox_generator'
require 'active_outbox/outboxable'
require 'active_outbox/railtie' if defined?(Rails::Railtie)
require 'dry-configurable'

module ActiveOutbox
extend Dry::Configurable

setting :adapter, default: :sqlite
setting :outbox_mapping, default: {}
end
28 changes: 0 additions & 28 deletions lib/active_outbox/configuration.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/active_outbox/outboxable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def outbox_model_name!
def namespace_outbox_mapping
namespace = self.class.name.split('/').first

ActiveOutbox.configuration.outbox_mapping[namespace&.underscore]
ActiveOutbox.config.outbox_mapping[namespace&.underscore]
end

def default_outbox_mapping
ActiveOutbox.configuration.outbox_mapping['default']
ActiveOutbox.config.outbox_mapping['default']
end

def handle_outbox_errors(outbox)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/active_outbox/outboxable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
context 'when record is created' do
context 'when the ActiveOutbox configuration is not set' do
before do
allow(ActiveOutbox.configuration).to receive(:outbox_mapping).and_return({ 'default' => nil })
allow(ActiveOutbox.config).to receive(:outbox_mapping).and_return({ 'default' => nil })
end

include_examples 'raises an error and does not create neither the record nor the outbox record',
Expand Down

0 comments on commit 4ebff3c

Please sign in to comment.