Class: Sanction::AttachedList
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Sanction::AttachedList
show all
- Defined in:
- lib/sanction/attached_list.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(array = []) ⇒ AttachedList
Returns a new instance of AttachedList.
6
7
8
|
# File 'lib/sanction/attached_list.rb', line 6
def initialize(array = [])
super(array)
end
|
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
4
5
6
|
# File 'lib/sanction/attached_list.rb', line 4
def key
@key
end
|
#parent ⇒ Object
Returns the value of attribute parent.
4
5
6
|
# File 'lib/sanction/attached_list.rb', line 4
def parent
@parent
end
|
Instance Method Details
#[](index) ⇒ Object
10
11
12
|
# File 'lib/sanction/attached_list.rb', line 10
def [](index)
detect {|x| x.id == index} || wildcard_member || null_node_class.new({id: index, type: key, scope: []}, @parent)
end
|
#allowed_ids ⇒ Object
26
27
28
|
# File 'lib/sanction/attached_list.rb', line 26
def allowed_ids
[]
end
|
#denied_ids ⇒ Object
22
23
24
|
# File 'lib/sanction/attached_list.rb', line 22
def denied_ids
[]
end
|
#has_scope?(scope) ⇒ Boolean
30
31
32
|
# File 'lib/sanction/attached_list.rb', line 30
def has_scope? scope
@parent.has_scope? scope
end
|
#ids_blank? ⇒ Boolean
18
19
20
|
# File 'lib/sanction/attached_list.rb', line 18
def ids_blank?
denied_ids.blank? && allowed_ids.blank?
end
|
#resources ⇒ Object
46
47
48
|
# File 'lib/sanction/attached_list.rb', line 46
def resources
@parent.resources
end
|
#type ⇒ Object
14
15
16
|
# File 'lib/sanction/attached_list.rb', line 14
def type
key
end
|
#wildcard_member ⇒ Object
34
35
36
|
# File 'lib/sanction/attached_list.rb', line 34
def wildcard_member
detect {|x| x.wildcarded? }
end
|
#wildcard_resource? ⇒ Boolean
42
43
44
|
# File 'lib/sanction/attached_list.rb', line 42
def wildcard_resource?
resources.include?(:*)
end
|
#wildcarded? ⇒ Boolean
38
39
40
|
# File 'lib/sanction/attached_list.rb', line 38
def wildcarded?
!!wildcard_member
end
|