Module: Restful::Base::InstanceMethods
- Defined in:
- lib/restful/base.rb
Overview
Instance helper methods for a Restful controller
Instance Method Summary collapse
-
#collection ⇒ Object
Helper method that allows you to refer to the instance variable that represents the collection of objects from the model name defined in the restful macro.
-
#collection_path ⇒ Object
This is a helper method to get the object collection path.
-
#collection_url ⇒ Object
This is a helper method to get the object collection url.
-
#edit_resource_path(object) ⇒ Object
Generic route path helper method to edit a model.
-
#edit_resource_url(object) ⇒ Object
Generic route url helper method to edit a model.
-
#new_resource_path ⇒ Object
Generic route path helper method for new model.
-
#new_resource_url ⇒ Object
Generic route url helper method for new model.
-
#resource ⇒ Object
Helper method that allows you to refer to the instance variable that represent a single object from the model name defined in the restful macro.
-
#resource_class ⇒ Object
Helper method that gives you access to the class of your model.
Instance Method Details
#collection ⇒ Object
Helper method that allows you to refer to the instance variable that represents the collection of objects from the model name defined in the restful macro.
32 33 34 35 36 |
# File 'lib/restful/base.rb', line 32 def collection get_collection_ivar || begin set_collection_ivar class_name.all end end |
#collection_path ⇒ Object
This is a helper method to get the object collection path.
72 73 74 |
# File 'lib/restful/base.rb', line 72 def collection_path self.send route_prefix_to_method_name("#{class_name.model_name.route_key}_path") end |
#collection_url ⇒ Object
This is a helper method to get the object collection url.
78 79 80 |
# File 'lib/restful/base.rb', line 78 def collection_url self.send route_prefix_to_method_name("#{class_name.model_name.route_key}_url") end |
#edit_resource_path(object) ⇒ Object
Generic route path helper method to edit a model.
46 47 48 49 |
# File 'lib/restful/base.rb', line 46 def edit_resource_path(object) self.send route_prefix_to_method_name("edit_#{class_name.model_name.singular_route_key}_path"), object end |
#edit_resource_url(object) ⇒ Object
Generic route url helper method to edit a model.
53 54 55 56 |
# File 'lib/restful/base.rb', line 53 def edit_resource_url(object) self.send route_prefix_to_method_name("edit_#{class_name.model_name.singular_route_key}_url"), object end |
#new_resource_path ⇒ Object
Generic route path helper method for new model.
60 61 62 |
# File 'lib/restful/base.rb', line 60 def new_resource_path self.send route_prefix_to_method_name("new_#{class_name.model_name.singular_route_key}_path") end |
#new_resource_url ⇒ Object
Generic route url helper method for new model.
66 67 68 |
# File 'lib/restful/base.rb', line 66 def new_resource_url self.send route_prefix_to_method_name("new_#{class_name.model_name.singular_route_key}_url") end |
#resource ⇒ Object
Helper method that allows you to refer to the instance variable that represent a single object from the model name defined in the restful macro.
24 25 26 |
# File 'lib/restful/base.rb', line 24 def resource get_resource_ivar end |
#resource_class ⇒ Object
Helper method that gives you access to the class of your model.
40 41 42 |
# File 'lib/restful/base.rb', line 40 def resource_class class_name end |