4 ms·
extend ActiveSupport::Concern attr_accessor :foo class << self included do def method_missing(name) do define_meth
by stevebmark 8y ago
extend ActiveSupport::Concern
attr_accessor :foo
class << self
included do
def method_missing(name) do
define_method(:after_save) do |bar|
...
end
end
end
end
What do you mean? This stateful, first class mixin OO metaprogrammed magic, implicitly globally mixed in to your application, makes it super easy to understand the flow of your application and the capabilities of your system. It's also super easy to see where things are defined, and the structure of methods/classes/object doesn't depend on luck / the order your program _executes_ in! Fat models are the way to go, there's obviously no problem with stateful mixins to "separate" model logic and make sure your model can do absolutely everything, because what is data, really?
Perfect for junior and senior devs alike.
edit: I forgot to include `method_missing`, which definitely isn't a design flaw, and there's absolutely no fundamental community problem that Ruby developers don't see any problem with using it.
- eximius 8y agoThis is sarcastic right? I really can't tell. And you either deserve and upvote or a downvote and I can't tell which because of it.