Class: CanTango::Permits::Permit
- Inherits:
-
Object
- Object
- CanTango::Permits::Permit
show all
- Extended by:
- ClassMethods
- Includes:
- Api::Attributes, Helpers::Debug, CanTango::PermitEngine::Compatibility, CanTango::PermitEngine::RoleMatcher, CanTango::PermitEngine::Util, License, Execute, Rules
- Defined in:
- lib/cantango/permits/permit.rb,
lib/cantango/permits/permit/execute.rb,
lib/cantango/permits/permit/license.rb,
lib/cantango/permits/permit/class_methods.rb
Defined Under Namespace
Modules: ClassMethods, Execute, License
Instance Attribute Summary collapse
-
#ability ⇒ Object
readonly
strategy is used to control the owns strategy (see rules.rb).
-
#disabled ⇒ Object
readonly
strategy is used to control the owns strategy (see rules.rb).
Class Method Summary
collapse
Instance Method Summary
collapse
account_name, first_name, hash_key, type
#role_group_match?, #role_match?
#rules, #rules_1_4, #rules_1_5
#localhost_manager?, #permit_name, #role
Methods included from Execute
#cached_rules, #dynamic_rules, #execute, #executor, #include_cached, #include_non_cached, #non_cached_rules, #permit?, #permit_rules, #run_rule_methods, #static_rules
Methods included from Rules::Dsl
included, #scope
#debug
Constructor Details
#initialize(ability) ⇒ Permit
34
35
36
|
# File 'lib/cantango/permits/permit.rb', line 34
def initialize ability
@ability = ability
end
|
Instance Attribute Details
#ability ⇒ Object
strategy is used to control the owns strategy (see rules.rb)
17
18
19
|
# File 'lib/cantango/permits/permit.rb', line 17
def ability
@ability
end
|
#disabled ⇒ Object
strategy is used to control the owns strategy (see rules.rb)
17
18
19
|
# File 'lib/cantango/permits/permit.rb', line 17
def disabled
@disabled
end
|
Class Method Details
.available_permits ⇒ Object
29
30
31
|
# File 'lib/cantango/permits/permit.rb', line 29
def self.available_permits
CanTango.config.permits.available_permits
end
|
.inherited(subclass) ⇒ Object
21
22
23
|
# File 'lib/cantango/permits/permit.rb', line 21
def self.inherited(subclass)
register subclass.name.split('::').last.sub(/Permit$/, '').underscore.to_sym, subclass
end
|
.register(permit, subclass) ⇒ Object
25
26
27
|
# File 'lib/cantango/permits/permit.rb', line 25
def self.register permit, subclass
available_permits[permit] = subclass
end
|
Instance Method Details
#ability_rules ⇒ Object
42
43
44
|
# File 'lib/cantango/permits/permit.rb', line 42
def ability_rules
ability.send :rules
end
|
#ability_sync! ⇒ Object
82
83
84
85
|
# File 'lib/cantango/permits/permit.rb', line 82
def ability_sync!
ability_rules << (rules - ability_rules)
ability_rules.flatten!
end
|
#any(reg_exp) ⇒ Object
62
63
64
|
# File 'lib/cantango/permits/permit.rb', line 62
def any reg_exp
config.models.by_reg_exp reg_exp
end
|
#category(label) ⇒ Object
58
59
60
|
# File 'lib/cantango/permits/permit.rb', line 58
def category label
config.models.by_category label
end
|
#disable! ⇒ Object
46
47
48
|
# File 'lib/cantango/permits/permit.rb', line 46
def disable!
@disabled = true
end
|
#disabled? ⇒ Boolean
50
51
52
|
# File 'lib/cantango/permits/permit.rb', line 50
def disabled?
@disabled || config_disabled?
end
|
#localhost? ⇒ Boolean
74
75
76
|
# File 'lib/cantango/permits/permit.rb', line 74
def localhost?
config.localhost_list.include? request.host
end
|
#permit_type ⇒ Object
38
39
40
|
# File 'lib/cantango/permits/permit.rb', line 38
def permit_type
self.class.type
end
|
#publichost? ⇒ Boolean
78
79
80
|
# File 'lib/cantango/permits/permit.rb', line 78
def publichost?
!localhost?
end
|
#valid_for?(subject) ⇒ Boolean
54
55
56
|
# File 'lib/cantango/permits/permit.rb', line 54
def valid_for? subject
raise NotImplementedError
end
|