service_crud 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +7 -7
- data/lib/service_crud/service_crud.rb +8 -2
- metadata +6 -6
data/README.markdown
CHANGED
@@ -33,15 +33,15 @@ That's it. You can now GET, POST, PUT, and DELETE books through the standard RES
|
|
33
33
|
Sometimes you need to do a little extra work on your data before/after you create/update/destroy. And sometimes that can't be pushed down to the ORM layer.
|
34
34
|
For example, suppose we want to set the `:updated_by` property on our model to the `current_user`. We could simply:
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
class BooksController
|
37
|
+
include ServiceCrud
|
38
|
+
before_update :set_updated_by
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
private
|
41
|
+
def set_updated_by(model)
|
42
|
+
model.update_by = current_user
|
43
|
+
end
|
43
44
|
end
|
44
|
-
end
|
45
45
|
|
46
46
|
ServiceCrud supports the following callbacks: `before_create`, `after_create`, `before_update`, `after_update`, `before_destroy`, and `after_destroy`.
|
47
47
|
|
@@ -79,8 +79,14 @@ module ServiceCrud
|
|
79
79
|
@model = self.class.model.send self.class.orm_methods.find, params[:id]
|
80
80
|
|
81
81
|
respond_to do |format|
|
82
|
-
format.xml
|
83
|
-
|
82
|
+
format.xml do
|
83
|
+
render :status => 404, :text => "" and return unless @model
|
84
|
+
render :xml => @model
|
85
|
+
end
|
86
|
+
format.json do
|
87
|
+
render :status => 404, :text => "" and return unless @model
|
88
|
+
render :json => @model
|
89
|
+
end
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_crud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Parker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-17 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -52,8 +52,8 @@ homepage: http://github.com/moonmaster9000/service_crud
|
|
52
52
|
licenses: []
|
53
53
|
|
54
54
|
post_install_message:
|
55
|
-
rdoc_options:
|
56
|
-
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
57
|
require_paths:
|
58
58
|
- lib
|
59
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|