Comment Comment by t-writescode To add, the above code is a pretty near approximation of the literal code inside the devise codebase, which is a very standard Ruby auth system.See here:https://github.com/heartcombo/devise/blob/main/lib/devise/co... def self.define_helpers(mapping) #:nodoc: mapping = mapping.name class_eval <<-METHODS, __FILE__, __LINE__ + 1 def authenticate_#{mapping}!(opts = {}) That code is *literally* calling class_eval with a multi-line string parameter, where it inlines the helper name (like admin, user, whatever), to grow the class at runtime.It hurts my soul. parent t-writescode 1 year ago
See here:
https://github.com/heartcombo/devise/blob/main/lib/devise/co...
That code is *literally* calling class_eval with a multi-line string parameter, where it inlines the helper name (like admin, user, whatever), to grow the class at runtime.It hurts my soul.