Class: Saruman::ControllerBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ControllerBuilder

Returns a new instance of ControllerBuilder.



297
298
299
300
# File 'lib/saruman.rb', line 297

def initialize(options)
  @options = options
  ask_question
end

Instance Method Details

#ask_questionObject



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/saruman.rb', line 302

def ask_question
  controller = Saruman::Controller.new(@options)
  controller.name = ask("Enter Controller Name (will match www.yourmagentoinstall.com/frontname/controllername)") { |q| q.default = "index" }
  controller_actions_input = ask("Enter list of actions for this controller, I.E., index show add") { |q| q.default = "index show add"}
  controller.actions = parse_controller_actions(controller_actions_input)
  
  say("Would you like to create controller action views?")
  choose do |menu|
    menu.choice(:yes) { controller.create_views = true }
    menu.choice(:no) { controller.create_views  = false }
  end
  
  # @question_answer = {:controller_name => controller_name.capitalize, :controller_actions => controller_actions}
  @question_answer = controller
  @question_answer
end

#outputObject



319
320
321
# File 'lib/saruman.rb', line 319

def output
  return @question_answer
end

#parse_controller_actions(controller_actions_input) ⇒ Object



323
324
325
326
327
328
329
# File 'lib/saruman.rb', line 323

def parse_controller_actions(controller_actions_input)
  actions = []
  controller_actions_input.split(" ").each do |action|
    actions << Saruman::ControllerBuilderAction.new(action)
  end
  actions
end