simonmenke-render_any 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/rails/init.rb +18 -2
- metadata +7 -9
- data/MIT-LICENSE.txt +0 -20
- data/README.rdoc +0 -91
data/rails/init.rb
CHANGED
@@ -26,6 +26,22 @@ end
|
|
26
26
|
render
|
27
27
|
end
|
28
28
|
|
29
|
+
s.index do |object, options|
|
30
|
+
render :action => (options[:action] || 'index')
|
31
|
+
end
|
32
|
+
|
33
|
+
s.show do |object, options|
|
34
|
+
render :action => (options[:action] || 'show')
|
35
|
+
end
|
36
|
+
|
37
|
+
s.new do |object, options|
|
38
|
+
render :action => (options[:action] || 'new')
|
39
|
+
end
|
40
|
+
|
41
|
+
s.edit do |object, options|
|
42
|
+
render :action => (options[:action] || 'edit')
|
43
|
+
end
|
44
|
+
|
29
45
|
s.not_found do |object, options|
|
30
46
|
render_optional_error_file :not_found
|
31
47
|
end
|
@@ -39,7 +55,7 @@ end
|
|
39
55
|
end
|
40
56
|
|
41
57
|
s.create_failed do |object, options|
|
42
|
-
render :action => 'new'
|
58
|
+
render :action => (options[:action_failed] || 'new')
|
43
59
|
end
|
44
60
|
|
45
61
|
s.update do |object, options|
|
@@ -47,7 +63,7 @@ end
|
|
47
63
|
end
|
48
64
|
|
49
65
|
s.update_failed do |object, options|
|
50
|
-
render :action => 'edit'
|
66
|
+
render :action => (options[:action_failed] || 'edit')
|
51
67
|
end
|
52
68
|
|
53
69
|
s.destroy do |object, options|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonmenke-render_any
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
@@ -9,18 +9,18 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Automaticaly render an appropriate response.
|
17
17
|
email: simon.menke@gmail.com
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
24
|
files:
|
25
25
|
- test/render_any_test.rb
|
26
26
|
- test/test_helper.rb
|
@@ -30,9 +30,7 @@ files:
|
|
30
30
|
- lib/render_any.rb
|
31
31
|
- rails/init.rb
|
32
32
|
- tasks/render_any_tasks.rake
|
33
|
-
|
34
|
-
- README.rdoc
|
35
|
-
has_rdoc: true
|
33
|
+
has_rdoc: false
|
36
34
|
homepage: http://github.com/simonmenke/render_any
|
37
35
|
post_install_message:
|
38
36
|
rdoc_options: []
|
@@ -53,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
51
|
version:
|
54
52
|
requirements: []
|
55
53
|
|
56
|
-
rubyforge_project:
|
54
|
+
rubyforge_project:
|
57
55
|
rubygems_version: 1.2.0
|
58
56
|
signing_key:
|
59
57
|
specification_version: 3
|
data/MIT-LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Simon Menke
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
= RenderAny
|
2
|
-
|
3
|
-
RenderAny allows you to describe how a (restful) controller behaves for a specific format.
|
4
|
-
|
5
|
-
|
6
|
-
== Example
|
7
|
-
|
8
|
-
This is an example controller which responds to <tt>:html</tt>, <tt>:xml</tt>, <tt>:json</tt> and <tt>:yaml</tt>
|
9
|
-
|
10
|
-
class PostsController < ApplicationController
|
11
|
-
def index
|
12
|
-
@posts = Post.all
|
13
|
-
render_any @posts
|
14
|
-
end
|
15
|
-
|
16
|
-
def show
|
17
|
-
@post = Post.find(params[:id])
|
18
|
-
render_any @post
|
19
|
-
end
|
20
|
-
|
21
|
-
def new
|
22
|
-
@post = Post.new
|
23
|
-
render_any @post
|
24
|
-
end
|
25
|
-
|
26
|
-
def edit
|
27
|
-
@post = Post.find(params[:id])
|
28
|
-
render_any @post
|
29
|
-
end
|
30
|
-
|
31
|
-
def create
|
32
|
-
@post = Post.new(params[:post])
|
33
|
-
render_create(@post) { @post.save }
|
34
|
-
end
|
35
|
-
|
36
|
-
def update
|
37
|
-
@post = Post.find(params[:id])
|
38
|
-
render_update(@post) { @post.update_attributes(params[:post]) }
|
39
|
-
end
|
40
|
-
|
41
|
-
def destroy
|
42
|
-
@post = Post.find(params[:id])
|
43
|
-
render_destroy(@post) { @post.destroy }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
== Adding a format
|
48
|
-
|
49
|
-
Adding a format is easy, just put something like this in an initializer.
|
50
|
-
|
51
|
-
RenderAny.register :html do |s|
|
52
|
-
|
53
|
-
s.default do |object, options|
|
54
|
-
render
|
55
|
-
end
|
56
|
-
|
57
|
-
s.not_found do |object, options|
|
58
|
-
render_optional_error_file :not_found
|
59
|
-
end
|
60
|
-
|
61
|
-
s.unprocessable_entity do |object, options|
|
62
|
-
render_optional_error_file :unprocessable_entity
|
63
|
-
end
|
64
|
-
|
65
|
-
s.create do |object, options|
|
66
|
-
redirect_to object
|
67
|
-
end
|
68
|
-
|
69
|
-
s.create_failed do |object, options|
|
70
|
-
render :action => 'new'
|
71
|
-
end
|
72
|
-
|
73
|
-
s.update do |object, options|
|
74
|
-
redirect_to object
|
75
|
-
end
|
76
|
-
|
77
|
-
s.update_failed do |object, options|
|
78
|
-
render :action => 'edit'
|
79
|
-
end
|
80
|
-
|
81
|
-
s.destroy do |object, options|
|
82
|
-
redirect_to [object.class.to_s.underscore.pluralize.to_sym]
|
83
|
-
end
|
84
|
-
|
85
|
-
s.destroy_failed do |object, options|
|
86
|
-
redirect_to object
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
Copyright (c) 2009 Simon Menke, released under the MIT license
|