giraffesoft-classy_resources 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +24 -0
- data/VERSION.yml +1 -1
- data/lib/classy_resources.rb +1 -0
- data/test/fixtures/active_record_test_app.rb +1 -0
- metadata +24 -5
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Classy Resources
|
2
2
|
|
3
|
+
With a simple, declarative syntax, you can create active_resource compatible REST APIs incredibly quickly.
|
4
|
+
|
3
5
|
Think resource_controller, except for Sinatra.
|
4
6
|
|
5
7
|
= Installation
|
@@ -29,6 +31,28 @@ The above declaration will create the five actions specified, each responding to
|
|
29
31
|
|
30
32
|
Since ClassyResources was designed to be active resource compatible, the params formats and return values are what AR expects.
|
31
33
|
|
34
|
+
= Overrides
|
35
|
+
|
36
|
+
In the above example, :posts would map to a Post class. If your class is named differently, you just override class_for. For example, if your Post class was stored in a module:
|
37
|
+
|
38
|
+
def class_for(resource)
|
39
|
+
MyModule.const_get(resource.to_s.singularize.classify.constantize)
|
40
|
+
end
|
41
|
+
|
42
|
+
Or, if you wanted to change how objects were being serialized:
|
43
|
+
|
44
|
+
def serialize(object, format)
|
45
|
+
MySerializer.new(object, format).to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
Other method signatures you might want to override:
|
49
|
+
|
50
|
+
- def load_collection(resource)
|
51
|
+
- def build_object(resource, params)
|
52
|
+
- def load_object(resource, id)
|
53
|
+
- def update_object(object, params) # Note that this doesn't save. It just changes the attributes.
|
54
|
+
- def destroy_object(object)
|
55
|
+
|
32
56
|
== Copyright
|
33
57
|
|
34
58
|
Copyright (c) 2008 James Golick, Daniel Haran, GiraffeSoft Inc.. See LICENSE for details.
|
data/VERSION.yml
CHANGED
data/lib/classy_resources.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giraffesoft-classy_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Golick
|
@@ -9,10 +9,29 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-16 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.2.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sinatra-sinatra
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.0.4
|
34
|
+
version:
|
16
35
|
description: TODO
|
17
36
|
email: james@giraffesoft.ca
|
18
37
|
executables: []
|
@@ -64,6 +83,6 @@ rubyforge_project:
|
|
64
83
|
rubygems_version: 1.2.0
|
65
84
|
signing_key:
|
66
85
|
specification_version: 2
|
67
|
-
summary:
|
86
|
+
summary: Instant ActiveResource compatible resources. Think resource_controller, for sinatra.
|
68
87
|
test_files: []
|
69
88
|
|