module DefaultController
Constants
- VERSION
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/default_controller.rb, line 3 def initialize res_name=self.class.name.sub("Controller", "") @model=res_name.singularize @objname =@model.downcase @objsname=res_name.downcase super end
Public Instance Methods
create()
click to toggle source
# File lib/default_controller.rb, line 48 def create instance_variable_set("@#{@objname}", create_obj) get_obj.save respond_with(get_obj) end
create_obj()
click to toggle source
# File lib/default_controller.rb, line 25 def create_obj Kernel.const_get(@model).send("new",params[@objname.to_sym]) end
destroy()
click to toggle source
# File lib/default_controller.rb, line 66 def destroy find_obj.destroy redirect_to send("#{@objsname}_url") end
edit()
click to toggle source
# File lib/default_controller.rb, line 54 def edit find_obj respond end
find_by_id()
click to toggle source
# File lib/default_controller.rb, line 19 def find_by_id Kernel.const_get(@model).find(params[:id]) end
find_obj()
click to toggle source
# File lib/default_controller.rb, line 28 def find_obj instance_variable_set("@#{@objname}", find_by_id) get_obj end
get_obj()
click to toggle source
# File lib/default_controller.rb, line 10 def get_obj instance_variable_get("@#{@objname}") end
get_objs()
click to toggle source
# File lib/default_controller.rb, line 13 def get_objs instance_variable_get("@#{@objsname}") end
index()
click to toggle source
# File lib/default_controller.rb, line 40 def index instance_variable_set("@#{@objsname}", list_all) respond_all end
list_all()
click to toggle source
# File lib/default_controller.rb, line 16 def list_all Kernel.const_get(@model).send("all") end
new()
click to toggle source
# File lib/default_controller.rb, line 44 def new instance_variable_set("@#{@objname}", new_obj) get_obj end
new_obj()
click to toggle source
# File lib/default_controller.rb, line 22 def new_obj Kernel.const_get(@model).send("new") end
respond()
click to toggle source
# File lib/default_controller.rb, line 33 def respond respond_with(find_obj) end
respond_all()
click to toggle source
# File lib/default_controller.rb, line 36 def respond_all respond_with(get_objs) end
show()
click to toggle source
# File lib/default_controller.rb, line 62 def show find_obj respond end
update()
click to toggle source
# File lib/default_controller.rb, line 58 def update find_obj.update_attributes(params[@objname.to_sym]) respond end