Class: ResourceFull::Base
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ResourceFull::Base
- Defined in:
- lib/resource_full/base.rb
Direct Known Subclasses
Controllers::ResourcesController, Controllers::RoutesController
Class Method Summary collapse
-
.all_resources ⇒ Object
Returns the list of all resources handled by ResourceFull.
-
.controller_for(resource) ⇒ Object
Returns the controller for the given resource.
Instance Method Summary collapse
Class Method Details
.all_resources ⇒ Object
Returns the list of all resources handled by ResourceFull.
14 15 16 17 18 19 20 |
# File 'lib/resource_full/base.rb', line 14 def all_resources ActionController::Routing.possible_controllers.map do |possible_controller| controller_for(possible_controller) end.select do |controller_class| controller_class.ancestors.include?(self) end end |
.controller_for(resource) ⇒ Object
Returns the controller for the given resource.
23 24 25 26 27 28 |
# File 'lib/resource_full/base.rb', line 23 def controller_for(resource) return resource if resource.is_a?(Class) && resource.ancestors.include?(ActionController::Base) "#{resource.to_s.underscore}_controller".classify.constantize rescue NameError raise ResourceFull::ResourceNotFound, "not found: #{resource}" end |
Instance Method Details
#model_class ⇒ Object
10 |
# File 'lib/resource_full/base.rb', line 10 def model_class; self.class.model_class; end |
#model_name ⇒ Object
9 |
# File 'lib/resource_full/base.rb', line 9 def model_name; self.class.model_name; end |