Module: IAmICan
- Defined in:
- lib/i_am_i_can.rb,
lib/i_am_i_can/role.rb,
lib/i_am_i_can/subject.rb,
lib/i_am_i_can/version.rb,
lib/i_am_i_can/resource.rb,
lib/i_am_i_can/permission.rb,
lib/i_am_i_can/role/grouping.rb,
lib/i_am_i_can/configs/config.rb,
lib/i_am_i_can/configs/configs.rb,
lib/i_am_i_can/helpers/dynamic.rb,
lib/i_am_i_can/role/assignment.rb,
lib/i_am_i_can/role/definition.rb,
lib/i_am_i_can/helpers/result_of.rb,
lib/i_am_i_can/support/reflection.rb,
lib/i_am_i_can/support/configurable.rb,
lib/i_am_i_can/permission/assignment.rb,
lib/i_am_i_can/permission/definition.rb,
lib/i_am_i_can/role_group/definition.rb,
lib/i_am_i_can/subject/role_querying.rb,
lib/generators/i_am_i_can/setup_generator.rb,
lib/i_am_i_can/subject/permission_querying.rb,
lib/i_am_i_can/support/association_class_methods.rb
Defined Under Namespace
Modules: Association_ClassMethods, Configs, Configurable, Dynamic, Generators, Permission, Reflection, Resource, ResultOf, Role, RoleGroup, Subject
Classes: Error, InsufficientPermission, VerificationFailed
Constant Summary
collapse
- VERSION =
'4.3.2'
Instance Method Summary
collapse
Instance Method Details
#acts_as_allowed_resource ⇒ Object
82
83
84
|
# File 'lib/i_am_i_can.rb', line 82
def acts_as_allowed_resource
include Resource
end
|
#acts_as_permission ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/i_am_i_can.rb', line 70
def acts_as_permission
i_am_i_can&.act = :permission
include Reflection
include Permission
instance_exec(i[ role role_group ], &Dynamic.scopes)
instance_exec(&Dynamic.class_reflections)
before_create { self. ||= name.to_s.humanize }
validates :action, uniqueness: { scope: i[ obj_type obj_id ] }
end
|
#acts_as_role ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/i_am_i_can.rb', line 34
def acts_as_role
i_am_i_can&.act = :role
include Reflection
include Role
extend Permission::Definition
include Permission::Assignment
instance_exec(i[ subject role_group permission ], &Dynamic.scopes)
instance_exec(&Dynamic.class_reflections)
instance_exec(%w[ permission ], &Dynamic.assignment_helpers)
instance_exec(%w[ permission ], &Dynamic.definition_helpers)
before_create { self. ||= name.to_s.humanize }
validates :name, uniqueness: true
end
|
#acts_as_role_group ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/i_am_i_can.rb', line 51
def acts_as_role_group
i_am_i_can&.act = :role_group
include Reflection
include Role
include Role::Grouping
extend Permission::Definition
include Permission::Assignment
instance_exec(i[ permission role ], &Dynamic.scopes)
instance_exec(&Dynamic.class_reflections)
instance_exec(%w[ role permission ], &Dynamic.assignment_helpers)
instance_exec(%w[ permission ], &Dynamic.definition_helpers)
before_create { self. ||= name.to_s.humanize }
validates :name, uniqueness: true
end
|
#acts_as_subject ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/i_am_i_can.rb', line 17
def acts_as_subject
i_am_i_can&.act = :subject
include Reflection
include Subject
extend Role::Definition
include Role::Assignment
extend RoleGroup::Definition
include Subject::RoleQuerying
include Subject::PermissionQuerying
instance_exec(i[ role ], &Dynamic.scopes)
instance_exec(&Dynamic.class_reflections)
instance_exec(%w[ role ], &Dynamic.assignment_helpers)
instance_exec(%w[ role ], &Dynamic.definition_helpers)
end
|