Class: CanTango::Permit::Base
- Inherits:
-
Object
- Object
- CanTango::Permit::Base
show all
- Extended by:
- ClassMethods
- Includes:
- Api::Attributes, Helpers::Debug
- Defined in:
- lib/cantango/permit/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
finder, hash_key, inherited, type
#account_name, #permit_name
Constructor Details
#initialize(ability) ⇒ Base
26
27
28
|
# File 'lib/cantango/permit/base.rb', line 26
def initialize ability
@ability = ability
end
|
Instance Attribute Details
#ability ⇒ Object
strategy is used to control the owns strategy (see rules.rb)
15
16
17
|
# File 'lib/cantango/permit/base.rb', line 15
def ability
@ability
end
|
#disabled ⇒ Object
strategy is used to control the owns strategy (see rules.rb)
15
16
17
|
# File 'lib/cantango/permit/base.rb', line 15
def disabled
@disabled
end
|
#mode ⇒ Object
30
31
32
|
# File 'lib/cantango/permit/base.rb', line 30
def mode
@mode ||= :no_cache
end
|
Instance Method Details
#any(reg_exp) ⇒ Object
58
59
60
|
# File 'lib/cantango/permit/base.rb', line 58
def any reg_exp
CanTango.config.models.by_reg_exp reg_exp
end
|
#category(label) ⇒ Object
54
55
56
|
# File 'lib/cantango/permit/base.rb', line 54
def category label
CanTango.config.models.by_category label
end
|
#disable! ⇒ Object
42
43
44
|
# File 'lib/cantango/permit/base.rb', line 42
def disable!
@disabled = true
end
|
#disabled? ⇒ Boolean
46
47
48
|
# File 'lib/cantango/permit/base.rb', line 46
def disabled?
@disabled || CanTango.config.permits.disabled?(permit_type, name)
end
|
#modes ⇒ Object
34
35
36
|
# File 'lib/cantango/permit/base.rb', line 34
def modes
self.class.modes
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/cantango/permit/base.rb', line 19
def name
self.class.permit_name self.class
end
|
#permit_type ⇒ Object
38
39
40
|
# File 'lib/cantango/permit/base.rb', line 38
def permit_type
self.class.permit_type
end
|
#sync_rules! ⇒ Object
70
71
72
73
|
# File 'lib/cantango/permit/base.rb', line 70
def sync_rules!
ability.rules << (rules - ability_rules)
ability.rules.flatten!
end
|
#valid? ⇒ Boolean
50
51
52
|
# File 'lib/cantango/permit/base.rb', line 50
def valid?
raise NotImplementedError
end
|