Class: MVCLI::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/mvcli/controller.rb

Direct Known Subclasses

PluginsController

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, method, params) ⇒ Controller

Returns a new instance of Controller.



8
9
10
# File 'lib/mvcli/controller.rb', line 8

def initialize(name, method, params)
  @name, @method, @params = name, method, params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/mvcli/controller.rb', line 6

def params
  @params
end

Instance Method Details

#call(command) ⇒ Object



12
13
14
15
16
17
# File 'lib/mvcli/controller.rb', line 12

def call(command)
  response = send @method
  template = cortex.read :template, "#{@name}/#{@method}"
  template.call response, command.output
  return 0
end

#formObject



19
20
21
22
23
24
# File 'lib/mvcli/controller.rb', line 19

def form
  template = cortex.read :form, "#{@name}/#{@method}"
  form = template.new argv.options
  form.validate!
  form
end