has_scope 0.3 → 0.4
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.rdoc +18 -16
- data/Rakefile +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -52,30 +52,30 @@ If you want it as plugin, just do:
|
|
52
52
|
|
53
53
|
== Options
|
54
54
|
|
55
|
-
HasScope
|
55
|
+
HasScope supports several options:
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
* <tt>:type</tt> - Checks the type of the parameter sent. If set to :boolean
|
58
|
+
it just calls the named scope, without any argument. By default,
|
59
|
+
it does not allow hashes or arrays to be given, except if type
|
60
|
+
:hash or :array are set.
|
61
61
|
|
62
|
-
|
62
|
+
* <tt>:only</tt> - In which actions the scope is applied.
|
63
63
|
|
64
|
-
|
64
|
+
* <tt>:except</tt> - In which actions the scope is not applied.
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
* <tt>:as</tt> - The key in the params hash expected to find the scope.
|
67
|
+
Defaults to the scope name.
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
* <tt>:if</tt> - Specifies a method, proc or string to call to determine
|
70
|
+
if the scope should apply
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
* <tt>:unless</tt> - Specifies a method, proc or string to call to determine
|
73
|
+
if the scope should NOT apply.
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
* <tt>:default</tt> - Default value for the scope. Whenever supplied the scope
|
76
|
+
is always called.
|
77
77
|
|
78
|
-
|
78
|
+
* <tt>:allow_blank</tt> - Blank values are not sent to scopes by default. Set to true to overwrite.
|
79
79
|
|
80
80
|
== Block usage
|
81
81
|
|
@@ -87,6 +87,8 @@ need to manipulate the given value:
|
|
87
87
|
value != "all" ? scope.by_category(value) : scope
|
88
88
|
end
|
89
89
|
|
90
|
+
When used with booleans, it just receives two arguments and is just invoked if true is given:
|
91
|
+
|
90
92
|
has_scope :not_voted_by_me, :type => :boolean do |controller, scope|
|
91
93
|
scope.not_voted_by(controller.current_user.id)
|
92
94
|
end
|
data/Rakefile
CHANGED
@@ -27,7 +27,7 @@ begin
|
|
27
27
|
require 'jeweler'
|
28
28
|
Jeweler::Tasks.new do |s|
|
29
29
|
s.name = "has_scope"
|
30
|
-
s.version = "0.
|
30
|
+
s.version = "0.4"
|
31
31
|
s.summary = "Maps controller filters to your resource scopes"
|
32
32
|
s.email = "contact@plataformatec.com.br"
|
33
33
|
s.homepage = "http://github.com/plataformatec/has_scope"
|