Skip to content

Commit

Permalink
perf: reduce Configuration instances to the bare minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
ElMassimo committed Jun 26, 2024
1 parent ce859b2 commit 2aacfed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/inertia_rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def merge(config)
Configuration.new(**@options.merge(config.options))
end

# Internal: Finalizes the configuration for a specific controller.
def with_defaults(config)
@options = config.options.merge(@options)
freeze
end

OPTION_NAMES.each do |option|
define_method(option) {
evaluate_option @options[option]
Expand Down
2 changes: 1 addition & 1 deletion lib/inertia_rails/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def use_inertia_instance_props
def _inertia_configuration
@_inertia_configuration ||= begin
config = superclass.try(:_inertia_configuration) || ::InertiaRails.configuration
@inertia_config ? config.merge(@inertia_config.freeze).freeze : config
@inertia_config&.with_defaults(config) || config
end
end

Expand Down

0 comments on commit 2aacfed

Please sign in to comment.