Skip to content

Commit b4e7b59

Browse files
committed
Dropped ActiveSupport::Configurable.
Signed-off-by: Hermann Mayer <hermann.mayer92@gmail.com>
1 parent 075e168 commit b4e7b59

File tree

8 files changed

+50
-9
lines changed

8 files changed

+50
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
### next
22

3+
* Dropped Reek (#23)
34
* Added support for Rails 8.1 (#24)
4-
* Dropped Reek (#22)
5+
* Switched from `ActiveSupport::Configurable` to a custom implementation based
6+
on `ActiveSupport::OrderedOptions` (#25)
57

68
### 2.0.0 (28 June 2025)
79

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gemspec
1010
# Development dependencies
1111
gem 'appraisal', '~> 2.4'
1212
gem 'bundler', '~> 2.6'
13-
gem 'countless', '~> 2.0'
13+
gem 'countless', '~> 2.2'
1414
gem 'factory_bot', '~> 6.2'
1515
gem 'guard-rspec', '~> 4.7'
1616
gem 'railties', '>= 7.1'

gemfiles/rails_7.1.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "https://rubygems.org"
44

55
gem "appraisal", "~> 2.4"
66
gem "bundler", "~> 2.6"
7-
gem "countless", "~> 2.0"
7+
gem "countless", "~> 2.2"
88
gem "factory_bot", "~> 6.2"
99
gem "guard-rspec", "~> 4.7"
1010
gem "railties", ">= 7.1"

gemfiles/rails_7.2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "https://rubygems.org"
44

55
gem "appraisal", "~> 2.4"
66
gem "bundler", "~> 2.6"
7-
gem "countless", "~> 2.0"
7+
gem "countless", "~> 2.2"
88
gem "factory_bot", "~> 6.2"
99
gem "guard-rspec", "~> 4.7"
1010
gem "railties", ">= 7.1"

gemfiles/rails_8.0.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "https://rubygems.org"
44

55
gem "appraisal", "~> 2.4"
66
gem "bundler", "~> 2.6"
7-
gem "countless", "~> 2.0"
7+
gem "countless", "~> 2.2"
88
gem "factory_bot", "~> 6.2"
99
gem "guard-rspec", "~> 4.7"
1010
gem "railties", ">= 7.1"

gemfiles/rails_8.1.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "https://rubygems.org"
44

55
gem "appraisal", "~> 2.4"
66
gem "bundler", "~> 2.6"
7-
gem "countless", "~> 2.0"
7+
gem "countless", "~> 2.2"
88
gem "factory_bot", "~> 6.2"
99
gem "guard-rspec", "~> 4.7"
1010
gem "railties", ">= 7.1"

lib/immoscout.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
require 'logger'
55
require 'active_support'
66
require 'active_support/concern'
7-
require 'active_support/configurable'
7+
require 'active_support/ordered_options'
8+
require 'active_support/core_ext/class/attribute'
89
require 'active_support/core_ext/hash'
910
require 'active_support/core_ext/module'
1011
require 'singleton'

lib/immoscout/configuration.rb

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,46 @@
22

33
module Immoscout
44
# The configuration object of the +immoscout+ gem.
5-
class Configuration
6-
include ActiveSupport::Configurable
5+
class Configuration < ActiveSupport::OrderedOptions
6+
# Track our configurations settings (+Symbol+ keys) and their defaults as
7+
# lazy-loaded +Proc+'s values
8+
class_attribute :defaults,
9+
instance_reader: true,
10+
instance_writer: false,
11+
instance_predicate: false,
12+
default: {}
13+
14+
# Create a new +Configuration+ instance with all settings populated with
15+
# their respective defaults.
16+
#
17+
# @param args [Hash{Symbol => Mixed}] additional settings which
18+
# overwrite the defaults
19+
# @return [Configuration] the new configuration instance
20+
def initialize(**args)
21+
super()
22+
defaults.each { |key, default| self[key] = instance_exec(&default) }
23+
merge!(**args)
24+
end
25+
26+
# A simple DSL method to define new configuration accessors/settings with
27+
# their defaults. The defaults can be retrieved with
28+
# +Configuration.defaults+ or +Configuration.new.defaults+.
29+
#
30+
# @param name [Symbol, String] the name of the configuration
31+
# accessor/setting
32+
# @param default [Mixed, nil] a non-lazy-loaded static value, serving as a
33+
# default value for the setting
34+
# @param block [Proc] when given, the default value will be lazy-loaded
35+
# (result of the Proc)
36+
def self.config_accessor(name, default = nil, &block)
37+
# Save the given configuration accessor default value
38+
defaults[name.to_sym] = block || -> { default }
39+
40+
# Compile reader/writer methods so we don't have to go through
41+
# +ActiveSupport::OrderedOptions#method_missing+.
42+
define_method(name) { self[name] }
43+
define_method("#{name}=") { |value| self[name] = value }
44+
end
745

846
config_accessor(:consumer_key) { ENV.fetch('IMMOSCOUT_CONSUMER_KEY', nil) }
947
config_accessor(:consumer_secret) do

0 commit comments

Comments
 (0)