From 5bc4ce6bdf072d0c5ca1a21e91fbac5f3b29b0b0 Mon Sep 17 00:00:00 2001 From: Teo Ljungberg Date: Sat, 25 May 2024 08:57:17 +0200 Subject: [PATCH] Move configuration methods to `Fx` (#130) Rather than having `lib/fx/configuration.rb` re-open the `Fx` module, it makes more sense to have the methods for `Fx.configuration`, `Fx.configuration=`, and `Fx.configure` live inside `lib/fx.rb`. --- lib/fx.rb | 25 +++++++++++++++++++++++++ lib/fx/configuration.rb | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/fx.rb b/lib/fx.rb index 31ae3f4a..3c700982 100644 --- a/lib/fx.rb +++ b/lib/fx.rb @@ -33,6 +33,31 @@ def self.load ) end + # @return [Fx::Configuration] F(x)'s current configuration + def self.configuration + @_configuration ||= Configuration.new + end + + # Set F(x)'s configuration + # + # @param config [Fx::Configuration] + def self.configuration=(config) + @_configuration = config + end + + # Modify F(x)'s current configuration + # + # @yieldparam [Fx::Configuration] config current F(x) config + # ``` + # Fx.configure do |config| + # config.database = Fx::Adapters::Postgres + # config.dump_functions_at_beginning_of_schema = true + # end + # ``` + def self.configure + yield configuration + end + # The current database adapter used by F(x). # # This defaults to {Fx::Adapters::Postgres} but can be overridden diff --git a/lib/fx/configuration.rb b/lib/fx/configuration.rb index bd158fe5..8862f9af 100644 --- a/lib/fx/configuration.rb +++ b/lib/fx/configuration.rb @@ -1,29 +1,4 @@ module Fx - # @return [Fx::Configuration] F(x)'s current configuration - def self.configuration - @_configuration ||= Configuration.new - end - - # Set F(x)'s configuration - # - # @param config [Fx::Configuration] - def self.configuration=(config) - @_configuration = config - end - - # Modify F(x)'s current configuration - # - # @yieldparam [Fx::Configuration] config current F(x) config - # ``` - # Fx.configure do |config| - # config.database = Fx::Adapters::Postgres - # config.dump_functions_at_beginning_of_schema = true - # end - # ``` - def self.configure - yield configuration - end - # F(x)'s configuration object. class Configuration # The F(x) database adapter instance to use when executing SQL.