Skip to content

Instantly share code, notes, and snippets.

@adam12
Created February 29, 2024 19:58
Show Gist options
  • Save adam12/67bdefa21f7042a0730c4be9954c0e80 to your computer and use it in GitHub Desktop.
Save adam12/67bdefa21f7042a0730c4be9954c0e80 to your computer and use it in GitHub Desktop.
module WebAction
def self.inherited(subclass)
super
subclass.prepend Callable
end
module Callable
# Set up instance method that accepts env, request, response
# and calls method inside Action without any arguments.
def call(env, request, response)
@env = env
@_request = request
@_response = response
super()
end
end
end
class SomeAction
include WebAction
def call
# Look mah, no arguments
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment