lib/mvcli/controller.rb in mvcli-0.0.16 vs lib/mvcli/controller.rb in mvcli-0.1.0
- old
+ new
@@ -1,7 +1,25 @@
+require "mvcli/erb"
+require "mvcli/form"
+
class MVCLI::Controller
+ requires :command, :cortex, :argv
attr_reader :params
- def initialize(params = {})
- @params = params
+ def initialize(name, method, params)
+ @name, @method, @params = name, method, params
+ end
+
+ def call(command)
+ response = send @method
+ template = cortex.read :template, "#{@name}/#{@method}"
+ template.call response, command.output
+ return 0
+ end
+
+ def form
+ template = cortex.read :form, "#{@name}/#{@method}"
+ form = template.new argv.options
+ form.validate!
+ form
end
end