Module: Fib::Additions::TargeterAddition
- Extended by:
- ActiveSupport::Concern
- Includes:
- ContainerAddition
- Defined in:
- lib/fib/additions/targeter_addition.rb
Instance Method Summary
collapse
#fib_container, #fib_inherit
Instance Method Details
#add_permissions(*permission_keys) ⇒ Object
33
34
35
36
37
|
# File 'lib/fib/additions/targeter_addition.rb', line 33
def add_permissions *permission_keys
new_permissions = fib_container.permissions. permission_keys
@permissions += new_permissions
save_permissions
end
|
#clear_permissions ⇒ Object
45
46
47
48
|
# File 'lib/fib/additions/targeter_addition.rb', line 45
def clear_permissions
fib_container.fpa.clear fib_redis_key
@permissions = nil
end
|
#create_permissions(*permission_keys) ⇒ Object
22
23
24
25
26
|
# File 'lib/fib/additions/targeter_addition.rb', line 22
def create_permissions *permission_keys
clear_permissions
new_permissions permission_keys
save_permissions
end
|
#del_permissions(*permission_keys) ⇒ Object
39
40
41
42
43
|
# File 'lib/fib/additions/targeter_addition.rb', line 39
def del_permissions *permission_keys
del_permissions = fib_container.permissions. permission_keys
@permissions -= del_permissions
save_permissions
end
|
#fib_identify ⇒ Object
58
59
60
61
|
# File 'lib/fib/additions/targeter_addition.rb', line 58
def fib_identify
raise UnSetTargeterIdentify, "Please rewrite [fib_identify] method and set only sign in #{self.class.name}" unless respond_to? :id
id
end
|
#fib_redis_key ⇒ Object
54
55
56
|
# File 'lib/fib/additions/targeter_addition.rb', line 54
def fib_redis_key
"Fib:#{fib_container.key}:#{self.class.name}:#{fib_identify}"
end
|
#get_persistence_permissions ⇒ Object
50
51
52
|
# File 'lib/fib/additions/targeter_addition.rb', line 50
def get_persistence_permissions
fib_container.restore_permissions(fib_redis_key)
end
|
#new_permissions(*permission_keys) ⇒ Object
28
29
30
31
|
# File 'lib/fib/additions/targeter_addition.rb', line 28
def new_permissions *permission_keys
permission_keys = [permission_keys].flatten
@permissions = fib_container.permissions. permission_keys
end
|
#permissions ⇒ Object
10
11
12
|
# File 'lib/fib/additions/targeter_addition.rb', line 10
def permissions
@permissions ||= permissions_scope & (get_persistence_permissions || Fib::PermissionsCollection.new)
end
|
#permissions_scope ⇒ Object
14
15
16
|
# File 'lib/fib/additions/targeter_addition.rb', line 14
def permissions_scope
fib_inherit.permissions
end
|
#save_permissions ⇒ Object
18
19
20
|
# File 'lib/fib/additions/targeter_addition.rb', line 18
def save_permissions
fib_container.fpa.save fib_redis_key, permissions.keys
end
|