snorlax 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -10
- data/app/controllers/snorlax/base.rb +1 -1
- data/lib/snorlax/version.rb +1 -1
- data/lib/snorlax.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: d6d01c9be95a6a09f2b95508b9a7bd95a7df93a2
|
4
|
+
data.tar.gz: 4ca7cea8aa4a0113e8ef3384591c6e0af7ff6a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cecf771da9bcd04f93d194be38584813941bfd7bbd38f2b96e3dd7877c9ff4a705de4896762c1c87e1c00605f42245fd8ee4efb45a5d458b9a496c11614dd52f
|
7
|
+
data.tar.gz: 175f940f1daacce9d660aeaa2fc03314b717bde28d7036dfc695a0d1e6ea0f81b91906e57d16e92d5292eda78373d5294c0bbc1650c0a66f87a3c1cca6766d28
|
data/README.md
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
# Snorlax
|
2
2
|
|
3
|
-
|
3
|
+
![](http://img3.wikia.nocookie.net/__cb20140924022259/pokemon/images/9/9f/143Snorlax_OS_anime.png)
|
4
4
|
|
5
|
-
|
5
|
+
Snorlax is an opinionated, flexible, and well-RESTed gem for building Rails APIs. It's designed to Do The Right Thing™ by default, but allow you to customize where necessary.
|
6
|
+
|
7
|
+
It's been extracted from [Loomio](www.github.com/loomio/loomio).
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
10
12
|
|
11
13
|
```ruby
|
12
|
-
gem '
|
14
|
+
gem 'snorlax'
|
13
15
|
```
|
14
16
|
|
15
17
|
And then execute:
|
@@ -18,22 +20,47 @@ And then execute:
|
|
18
20
|
|
19
21
|
Or install it yourself as:
|
20
22
|
|
21
|
-
$ gem install
|
23
|
+
$ gem install snorlax
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
There are two primary ways to use Snorlax. The easier way is to inherit from it:
|
26
28
|
|
27
|
-
|
29
|
+
```
|
30
|
+
class MyController < Snorlax::Base
|
31
|
+
end
|
32
|
+
```
|
28
33
|
|
29
|
-
|
34
|
+
But, if you're already inheriting from something else, Snorlax makes it easy to simply apply itself to your controller without being a parent, by calling `snorlax_used_rest!` like so:
|
30
35
|
|
31
|
-
|
36
|
+
```
|
37
|
+
class MyController < SomeOtherController
|
38
|
+
snorlax_used_rest!
|
39
|
+
end
|
40
|
+
```
|
32
41
|
|
33
|
-
|
42
|
+
Once you've got it installed, you're good to go!
|
43
|
+
|
44
|
+
TODO:
|
45
|
+
- Expand on show action
|
46
|
+
- - respond_with_resource
|
47
|
+
- explanation of side-loading
|
48
|
+
- Expand on index action
|
49
|
+
- - accessible and public records (required)
|
50
|
+
- - default page size
|
51
|
+
- From, to, per, since, until, timeframe_for parameters
|
52
|
+
- Toggling pagination / timeframing
|
53
|
+
- Customizing the serializer options
|
54
|
+
- Expand on create / update action
|
55
|
+
- create_action, update_action overriding
|
56
|
+
- respond_with_resource
|
57
|
+
- Expand on destroy action [destroy_action]
|
58
|
+
- destroy_action overriding
|
59
|
+
- Explain the respond_with_errors behaviour
|
34
60
|
|
35
|
-
|
61
|
+
## Contributing
|
36
62
|
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gdpelican/snorlax. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
37
64
|
|
38
65
|
## License
|
39
66
|
|
data/lib/snorlax/version.rb
CHANGED
data/lib/snorlax.rb
CHANGED
@@ -8,6 +8,6 @@ class ActionController::Base
|
|
8
8
|
# Method to allow controllers to apply Snorlax to themselves
|
9
9
|
# (g@nked from Inherited resources: https://github.com/josevalim/inherited_resources/blob/master/lib/inherited_resources.rb)
|
10
10
|
def self.snorlax_used_rest!
|
11
|
-
|
11
|
+
Snorlax::Base.snorlax_used_rest!(self)
|
12
12
|
end
|
13
13
|
end
|