Skip to content

Instantly share code, notes, and snippets.

@BDQ
Created May 26, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BDQ/3ea49a04486413b5e65e to your computer and use it in GitHub Desktop.
Save BDQ/3ea49a04486413b5e65e to your computer and use it in GitHub Desktop.
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