permissify 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/permissify/controller/controller_generator.rb +0 -1
- data/lib/generators/permissify/product/product_generator.rb +1 -1
- data/lib/permissify/controller.rb +18 -1
- data/spec/spec_helper.rb +1 -1
- metadata +3 -4
- data/lib/generators/permissify/controller/template/permissified_controller.rb +0 -10
@@ -7,7 +7,7 @@ module Permissify
|
|
7
7
|
|
8
8
|
copy_file "product.rb", "app/models/product.rb"
|
9
9
|
copy_file "products.rb", "app/models/system_fixtures/products.rb"
|
10
|
-
copy_file "controller.rb","app/
|
10
|
+
copy_file "controller.rb","app/controllers/products_controller.rb"
|
11
11
|
copy_file "helper.rb", "app/helpers/products_helper.rb"
|
12
12
|
|
13
13
|
directory "interface", "app/models/permissified_products_interface"
|
@@ -33,10 +33,27 @@ module Permissify
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def permissified_model_permissions(applicablity)
|
36
|
-
|
36
|
+
|
37
|
+
# There is some app-specific glue between the *applicability* tags specified when *abilities* are created (abilities.rb)
|
38
|
+
# and the ability/permission applicability that a permissifed object obtained from an app-supplied controller method governs.
|
39
|
+
# In more tangible terms:
|
40
|
+
# - the User obtained from the controller method 'current_user'
|
41
|
+
# contributes permissions for abilities which apply to the 'Role' applicability tag
|
42
|
+
# - the merchant (or brand or ...) obtained from the controller method 'current_entity'
|
43
|
+
# contributes permissions for abilities which apply to the 'Product' applicability tag
|
44
|
+
|
45
|
+
# Define PERMISSIFY in your application_controller when your app does not conform with the conventional_permissify_map.
|
46
|
+
|
47
|
+
permissify_map = defined?(self.class::PERMISSIFY) ? self.class::PERMISSIFY : conventional_permissify_map
|
48
|
+
permissified_model_method = permissify_map[applicablity]
|
37
49
|
permissified_model = send(permissified_model_method)
|
38
50
|
permissified_model ? permissified_model.permissions : Hash.new({})
|
39
51
|
end
|
40
52
|
|
53
|
+
def conventional_permissify_map
|
54
|
+
{ Role::PERMISSIFIED_ABILITY_APPLICABILITY => :current_user,
|
55
|
+
Product::PERMISSIFIED_ABILITY_APPLICABILITY => :current_entity,
|
56
|
+
}
|
57
|
+
end
|
41
58
|
end
|
42
59
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -69,5 +69,5 @@ class PermissifiedControllerish
|
|
69
69
|
include Permissify::Controller
|
70
70
|
PERMISSIFY = { Userish::PERMISSIFIED_ABILITY_APPLICABILITY => :current_user,
|
71
71
|
Entityish::PERMISSIFIED_ABILITY_APPLICABILITY => :current_entity,
|
72
|
-
}
|
72
|
+
}
|
73
73
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: permissify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 26
|
10
|
+
version: 0.0.26
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Frederick Fix
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/generators/permissify/ability/template/ability.rb
|
63
63
|
- lib/generators/permissify/ability/USAGE
|
64
64
|
- lib/generators/permissify/controller/controller_generator.rb
|
65
|
-
- lib/generators/permissify/controller/template/permissified_controller.rb
|
66
65
|
- lib/generators/permissify/controller/template/permissions_controller.rb
|
67
66
|
- lib/generators/permissify/controller/USAGE
|
68
67
|
- lib/generators/permissify/install/install_generator.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module PermissifiedController # Interfaces : override/rewrite as needed for your app
|
2
|
-
|
3
|
-
# controller-accessible methods that app has implemented to access models that have been permissified.
|
4
|
-
PERMISSIFY = SPECIFY_PERMISSIFIED_MODEL_LIST_IN__APP__CONTROLLERS__PERMISSIFIED_CONTROLLER
|
5
|
-
|
6
|
-
# PERMISSIFY = { User::PERMISSIFIED_ABILITY_APPLICABILITY => :current_user,
|
7
|
-
# Product::PERMISSIFIED_ABILITY_APPLICABILITY => :current_entity,
|
8
|
-
# }
|
9
|
-
|
10
|
-
end
|