Skip to content

Commit

Permalink
Clean up usage of ruby2_keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Aug 21, 2024
1 parent 49e947c commit a18e54f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions lib/trestle/evaluation_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ module Trestle
# both the Adapter/Navigation instance, as well as the controller/view from where they are invoked.
module EvaluationContext
protected
def self.ruby2_keywords(*)
end unless respond_to?(:ruby2_keywords, true)

# Missing methods are called on the given context if available.
#
# We include private methods as methods such as current_user
# are usually declared as private or protected.
ruby2_keywords def method_missing(name, *args, &block)
def method_missing(name, *args, &block)
if context_responds_to?(name)
@context.send(name, *args, &block)
else
super
end
end
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

def respond_to_missing?(name, include_private=false)
context_responds_to?(name) || super
Expand Down
6 changes: 2 additions & 4 deletions lib/trestle/form/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
module Trestle
class Form
class Renderer
def self.ruby2_keywords(*)
end unless respond_to?(:ruby2_keywords, true)

include ::ActionView::Context
include ::ActionView::Helpers::CaptureHelper

Expand Down Expand Up @@ -46,7 +43,7 @@ def fields_for(*args, &block)
concat(result)
end

ruby2_keywords def method_missing(name, *args, &block)
def method_missing(name, *args, &block)
target = @form.respond_to?(name) ? @form : @template

if block_given? && !RAW_BLOCK_HELPERS.include?(name)
Expand All @@ -63,6 +60,7 @@ def fields_for(*args, &block)
result
end
end
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

def respond_to_missing?(name, include_all=false)
@form.respond_to?(name, include_all) ||
Expand Down
6 changes: 2 additions & 4 deletions lib/trestle/toolbar/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def group
end

private
def self.ruby2_keywords(*)
end unless respond_to?(:ruby2_keywords, true)

ruby2_keywords def method_missing(name, *args, &block)
def method_missing(name, *args, &block)
result = builder.send(name, *args, &block)

if builder.builder_methods.include?(name)
Expand All @@ -33,6 +30,7 @@ def self.ruby2_keywords(*)
result
end
end
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)

def respond_to_missing?(name, include_all=false)
builder.respond_to?(name) || super
Expand Down

0 comments on commit a18e54f

Please sign in to comment.