Created
May 26, 2015 18:43
-
-
Save BDQ/3ea49a04486413b5e65e to your computer and use it in GitHub Desktop.
This file contains 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
require 'lotus-controller' | |
require 'byebug' | |
module Feature | |
def self.create(str) | |
str.reverse | |
end | |
end | |
module Sack | |
module ClassMethods | |
def operation(klass, method) | |
@klass = klass | |
@method = method | |
rescue Exception => boom | |
byebug | |
end | |
def invoke_operation(args) | |
@klass.send(@method, *args) | |
end | |
end | |
module InstanceMethods | |
def call(params) | |
self.body = self.class.invoke_operation(prepare params) | |
end | |
end | |
def self.included base | |
base.send :include, InstanceMethods | |
base.extend ClassMethods | |
end | |
end | |
class Show | |
include Lotus::Action | |
include Sack | |
operation Feature, :create | |
def prepare(params) | |
['tset a si siht'] | |
end | |
end | |
puts Show.new.call({ id: 23, key: 'value' }).inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment