Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource methods now in mixin to make overriding them easier
- Loading branch information
Showing
4 changed files
with
39 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Ardes | ||
module ResourcesController | ||
# methods which communicate with the resource_service to find/create resources | ||
module ResourceMethods | ||
protected | ||
# finds the collection of resources | ||
def find_resources | ||
resource_service.find :all | ||
end | ||
|
||
# finds the resource, using the passed id, defaults to the current params[:id] | ||
def find_resource(id = nil) | ||
id ||= respond_to?(:params) && params[:id] | ||
resource_service.find id | ||
end | ||
|
||
# makes a new resource, if attributes are not supplied, determine them from the | ||
# params hash and the current resource_name | ||
def new_resource(attributes = nil, &block) | ||
attributes ||= (respond_to?(:params) && params[resource_name]) || {} | ||
resource_service.new attributes, &block | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters