Skip to content

Commit 5631d5c

Browse files
committed
Make fixed locals support work on Ruby 2.0, which doesn't support required keyword arguments
Ruby 1.9 doesn't support keyword arguments at all, but the :fixed_locals option is only recognized on Tilt 2.6+, which requires Ruby 2.0+.
1 parent 9a94aad commit 5631d5c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/rodauth/features/base.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def csrf_tag(path=request.path)
410410

411411
def button_opts(value, opts)
412412
opts = Hash[template_opts].merge!(opts)
413-
_merge_fixed_locals_opts(opts, '(value:, opts:)')
413+
_merge_fixed_locals_opts(opts, button_fixed_locals)
414414
opts[:locals] = {:value=>value, :opts=>opts}
415415
opts[:cache] = cache_templates
416416
opts[:cache_key] = :rodauth_button
@@ -563,6 +563,20 @@ def _process_raw_hmac(hmac)
563563
s
564564
end
565565

566+
if RUBY_VERSION >= '2.1'
567+
def button_fixed_locals
568+
'(value:, opts:)'
569+
end
570+
# :nocov:
571+
else
572+
# Work on Ruby 2.0 when using Tilt 2.6+, as Ruby 2.0 does
573+
# not support required keyword arguments.
574+
def button_fixed_locals
575+
'(value: nil, opts: nil)'
576+
end
577+
end
578+
# :nocov:
579+
566580
def database_function_password_match?(name, hash_id, password, salt)
567581
db.get(Sequel.function(function_name(name), hash_id, password_hash_using_salt(password, salt)))
568582
end

0 commit comments

Comments
 (0)