canard 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.rdoc +1 -1
- data/lib/canard/adapters/active_record.rb +3 -0
- data/lib/canard/railtie.rb +4 -1
- data/lib/canard/version.rb +1 -1
- metadata +2 -2
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -141,7 +141,7 @@ to accept pull requests for tested Rails 2.x updates if anybody is game.
|
|
141
141
|
Canard is ORM agnostic. ActiveRecord and Mongoid (thanks David Butler) adapters are currently implemented.
|
142
142
|
New adapters can easily be added, but you'd need to check CanCan can also support your adapter.
|
143
143
|
|
144
|
-
|
144
|
+
== Further reading
|
145
145
|
|
146
146
|
Canard stands on the sholders of Ryan Bates' CanCan and Martin Rehfeld's RoleModel. You can read more
|
147
147
|
about defining abilities on the CanCan wiki (https://github.com/ryanb/cancan/wiki). Canard implements
|
@@ -5,11 +5,13 @@ module Canard
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def add_role_scopes
|
8
|
+
# TODO change to check has_roles_attribute?
|
8
9
|
if active_record_table?
|
9
10
|
valid_roles.each do |role|
|
10
11
|
define_scopes_for_role role
|
11
12
|
end
|
12
13
|
|
14
|
+
# TODO change hard coded :role_mask to roles_attribute_name
|
13
15
|
define_scope_method(:with_any_role) do |*roles|
|
14
16
|
where("#{role_mask_column} & :role_mask > 0", { :role_mask => mask_for(*roles) })
|
15
17
|
end
|
@@ -28,6 +30,7 @@ module Canard
|
|
28
30
|
respond_to?(:table_exists?) && table_exists?
|
29
31
|
end
|
30
32
|
|
33
|
+
# TODO extract has_roles_attribute? and change to has_roles_attribute? || super
|
31
34
|
def has_roles_mask_accessors?
|
32
35
|
active_record_table? && column_names.include?(roles_attribute_name.to_s) || super
|
33
36
|
end
|
data/lib/canard/railtie.rb
CHANGED
@@ -10,6 +10,9 @@ module Canard
|
|
10
10
|
app.config.eager_load_paths = app.config.eager_load_paths.reject do |path|
|
11
11
|
Canard.load_paths.include?(path)
|
12
12
|
end
|
13
|
+
if app.config.respond_to?(:watchable_dirs)
|
14
|
+
app.config.watchable_dirs.merge! Hash[ Canard.load_paths.product([[:rb]]) ]
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
initializer "canard.active_record" do |app|
|
@@ -20,7 +23,7 @@ module Canard
|
|
20
23
|
Canard.find_abilities
|
21
24
|
end
|
22
25
|
end
|
23
|
-
|
26
|
+
|
24
27
|
initializer "canard.mongoid" do |app|
|
25
28
|
if defined?(Mongoid)
|
26
29
|
require 'canard/adapters/mongoid'
|
data/lib/canard/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|