Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Implement Configuration class manually
Browse files Browse the repository at this point in the history
AS's Configurable is an overkill for our usecase and not worth adding
entire AS as a dependency.
  • Loading branch information
st0012 committed May 9, 2021
1 parent 8bfe981 commit 077df8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/tapping_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require "tapping_device/payload"
require "tapping_device/output"
require "tapping_device/trackable"
require "tapping_device/configurable"
require "tapping_device/configuration"
require "tapping_device/exceptions"
require "tapping_device/method_hijacker"
require "tapping_device/trackers/initialization_tracker"
Expand All @@ -27,7 +27,6 @@ class TappingDevice

extend Manageable

include Configurable
include Output::Helpers

def initialize(options = {}, &block)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
require "active_support/configurable"
require "active_support/concern"

class TappingDevice
module Configurable
extend ActiveSupport::Concern

class Configuration
DEFAULTS = {
filter_by_paths: [],
exclude_by_paths: [],
Expand All @@ -16,12 +11,24 @@ module Configurable
only_private: false
}.merge(TappingDevice::Output::DEFAULT_OPTIONS)

included do
include ActiveSupport::Configurable
def initialize
@options = {}

DEFAULTS.each do |key, value|
config[key] = value
@options[key] = value
end
end

def [](key)
@options[key]
end

def []=(key, value)
@options[key] = value
end
end

def self.config
@config ||= Configuration.new
end
end
2 changes: 1 addition & 1 deletion spec/configurable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
around do |example|
example.run

TappingDevice::Configurable::DEFAULTS.each do |key, value|
TappingDevice::Configuration::DEFAULTS.each do |key, value|
TappingDevice.config[key] = value
end
end
Expand Down

0 comments on commit 077df8f

Please sign in to comment.