Skip to content

Commit

Permalink
Move configuration methods to Fx (#130)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
teoljungberg authored May 25, 2024
1 parent c71a175 commit 5bc4ce6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 25 additions & 0 deletions lib/fx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions lib/fx/configuration.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 5bc4ce6

Please # to comment.