mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Add respond_to_missing? to classes defining method_missing to improve respond_to? behavior
This commit is contained in:
@@ -273,13 +273,6 @@ Style/MapToHash:
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/fee_summary.rb'
|
||||
- 'lib/tasks/sample_data/user_factory.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Style/MissingRespondToMissing:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/models/spree/gateway.rb'
|
||||
- 'app/models/spree/preferences/configuration.rb'
|
||||
|
||||
# Offense count: 38
|
||||
Style/OpenStructUse:
|
||||
Exclude:
|
||||
|
||||
@@ -45,6 +45,11 @@ module ApplicationHelper
|
||||
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &)
|
||||
end
|
||||
|
||||
def respond_to_missing?(method_name, include_private = false)
|
||||
(method_name.to_s.end_with?('_path',
|
||||
'_url') && spree.respond_to?(method_name, include_private)) || super
|
||||
end
|
||||
|
||||
# Pass URL helper calls on to spree where applicable so that we don't need to use
|
||||
# spree.foo_path in any view rendered from non-spree-namespaced controllers.
|
||||
def method_missing(method, *args, &)
|
||||
|
||||
@@ -30,6 +30,10 @@ module Spree
|
||||
preferences.transform_keys(&:to_sym)
|
||||
end
|
||||
|
||||
def respond_to_missing?(method_name, include_private = false)
|
||||
@provider.respond_to?(method_name, include_private) || super
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
if @provider.nil? || !@provider.respond_to?(method)
|
||||
super
|
||||
|
||||
@@ -57,6 +57,11 @@ module Spree
|
||||
set_preference args[0], args[1]
|
||||
end
|
||||
|
||||
def respond_to_missing?(method_name, include_private = false)
|
||||
name = method_name.to_s.chomp('=')
|
||||
has_preference?(name) || super
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
name = method.to_s.gsub('=', '')
|
||||
if has_preference? name
|
||||
|
||||
Reference in New Issue
Block a user