restaurant 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restaurant/restful_actions.rb +20 -2
- data/lib/restaurant/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34693c2b7b5744a24cb8d8b5996a0e71f864c224
|
4
|
+
data.tar.gz: 05751994c3c8c46fa048b739ef440f0b61a1b6df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed5df57787d9ae463a3b9f0163470c613769efc904add512f243d06db0a4b2ff421236d7909976accd30a02ede8a90a3fba64389a1e2e79f13e90093fd7bd91f
|
7
|
+
data.tar.gz: f19f4861e947ea6b6b1cb94907ee48f22c8a7654c21d35def38d68137b97629bacaa377b7d1b0302918e49f5466c8c5d6c205289708838ef7674e2a56d4f3083
|
@@ -1,4 +1,12 @@
|
|
1
1
|
module Restaurant::RestfulActions
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
rescue_from ActiveRecord::RecordNotFound do
|
6
|
+
head 404
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
def index
|
3
11
|
respond_with model.scoped, :only => current_role.allowed_attributes
|
4
12
|
end
|
@@ -22,14 +30,24 @@ module Restaurant::RestfulActions
|
|
22
30
|
private
|
23
31
|
|
24
32
|
def model
|
25
|
-
|
33
|
+
model_name.constantize
|
34
|
+
rescue NameError
|
35
|
+
define_model
|
36
|
+
end
|
37
|
+
|
38
|
+
def model_name
|
39
|
+
@model_name ||= self.class.name.sub(/Controller$/, "").singularize
|
26
40
|
end
|
27
41
|
|
28
42
|
def model_param
|
29
|
-
params[
|
43
|
+
params[model_name.underscore]
|
30
44
|
end
|
31
45
|
|
32
46
|
def resource
|
33
47
|
model.find(params[:id])
|
34
48
|
end
|
49
|
+
|
50
|
+
def define_model
|
51
|
+
Object.const_set(model_name, Class.new(ActiveRecord::Base))
|
52
|
+
end
|
35
53
|
end
|
data/lib/restaurant/version.rb
CHANGED