restrict 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -5
- data/lib/restrict/restriction.rb +4 -5
- data/lib/restrict/version.rb +1 -1
- data/spec/lib/restrict/gatekeeper_spec.rb +1 -1
- data/spec/lib/restrict/restriction_spec.rb +2 -6
- 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: 68a4da331094fb87ec736fbd19bfd69789b49df3
|
4
|
+
data.tar.gz: 57abb1a0b4c96ef18c13783a5ae15ed0d8e59016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24aaef845f178c795be551c1de4efa38d8cd750041b98d401a1c124483fb85f3e62b75e53d25e799316f232434108211a60fdc851f1f5ab4362563544109eca2
|
7
|
+
data.tar.gz: c85ac99aea25f9a20d7d17def516b27d1702223cd5d14c05586868a2b22881555c149995b26c4c3b4512c331e3690e3021ddf18b9ee88187b94ae314d90590b0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ What that does:
|
|
44
44
|
### Restrict all actions
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
restrict
|
47
|
+
restrict
|
48
48
|
```
|
49
49
|
|
50
50
|
This one will apply to all actions on this controller. It takes the `unless` option as well.
|
@@ -58,10 +58,6 @@ Restrict.config.authentication_validation_method = :admin_session_exists?
|
|
58
58
|
|
59
59
|
You may set the method that is used to figure out whether a user is signed in or not to whatever you like, however it's default is `:user_signed_in?` which is the most common (devise) method in use.
|
60
60
|
|
61
|
-
## Todo Ideas
|
62
|
-
|
63
|
-
* restrict :all_actions, except: [:new], unless: 'dsfsdf'
|
64
|
-
|
65
61
|
## Contributing
|
66
62
|
|
67
63
|
You know how this works and bonus points for feature branches!
|
data/lib/restrict/restriction.rb
CHANGED
@@ -3,10 +3,9 @@ module Restrict
|
|
3
3
|
attr_accessor :actions, :unless
|
4
4
|
|
5
5
|
def initialize(*args)
|
6
|
-
options
|
7
|
-
@unless
|
8
|
-
@actions
|
9
|
-
actions.empty? and raise ArgumentError, "expected actions to restrict, but got #{actions.inspect}"
|
6
|
+
options = args.extract_options!
|
7
|
+
@unless = options[:unless]
|
8
|
+
@actions = args
|
10
9
|
end
|
11
10
|
|
12
11
|
def applies_to?(action)
|
@@ -16,7 +15,7 @@ module Restrict
|
|
16
15
|
private
|
17
16
|
|
18
17
|
def applies_to_all_actions?
|
19
|
-
actions.
|
18
|
+
actions.empty?
|
20
19
|
end
|
21
20
|
|
22
21
|
def applies_to_action?(name)
|
data/lib/restrict/version.rb
CHANGED
@@ -7,10 +7,6 @@ describe Restrict::Restriction do
|
|
7
7
|
it 'knows about its actions' do
|
8
8
|
expect(restriction.actions).to eq [:show, :edit]
|
9
9
|
end
|
10
|
-
|
11
|
-
it 'raises an error if no actions were given' do
|
12
|
-
expect { Restrict::Restriction.new }.to raise_error(ArgumentError)
|
13
|
-
end
|
14
10
|
end
|
15
11
|
|
16
12
|
describe '#applies_to?' do
|
@@ -26,8 +22,8 @@ describe Restrict::Restriction do
|
|
26
22
|
expect(restriction).not_to be_applies_to(:index)
|
27
23
|
end
|
28
24
|
|
29
|
-
it 'returns true if it concerns
|
30
|
-
restriction = Restrict::Restriction.new
|
25
|
+
it 'returns true if it concerns all actions' do
|
26
|
+
restriction = Restrict::Restriction.new
|
31
27
|
expect(restriction).to be_applies_to(:foo)
|
32
28
|
expect(restriction).to be_applies_to(:bar)
|
33
29
|
end
|