Created
March 27, 2017 16:58
-
-
Save clemens/e4d01d78b7f407be8cc78544fe9fafb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trailblazer; end | |
module My; end | |
class Trailblazer::Operation | |
def self.inherited(klass) | |
*mod_names, klass_name = klass.name.split('::') | |
mod = const_get(mod_names.join('::')) | |
mod.define_singleton_method(klass_name) do |*args| | |
klass.new.call(*args) | |
end | |
end | |
end | |
class My::Operation < Trailblazer::Operation | |
def call(attributes = {}) | |
puts attributes.inspect | |
end | |
end | |
My::Operation(first_name: 'foo', last_name: 'bar') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment