Class: Sanction::AttachedList

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/sanction/attached_list.rb

Direct Known Subclasses

Blacklist::List, Whitelist::List

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

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/sanction/attached_list.rb', line 4

def key
  @key
end

#parentObject

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_idsObject



26
27
28
# File 'lib/sanction/attached_list.rb', line 26

def allowed_ids
  []
end

#denied_idsObject



22
23
24
# File 'lib/sanction/attached_list.rb', line 22

def denied_ids
  []
end

#has_scope?(scope) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sanction/attached_list.rb', line 30

def has_scope? scope
  @parent.has_scope? scope
end

#ids_blank?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sanction/attached_list.rb', line 18

def ids_blank?
  denied_ids.blank? && allowed_ids.blank?
end

#resourcesObject



46
47
48
# File 'lib/sanction/attached_list.rb', line 46

def resources
  @parent.resources
end

#typeObject



14
15
16
# File 'lib/sanction/attached_list.rb', line 14

def type
  key
end

#wildcard_memberObject



34
35
36
# File 'lib/sanction/attached_list.rb', line 34

def wildcard_member
  detect {|x| x.wildcarded? }
end

#wildcard_resource?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/sanction/attached_list.rb', line 42

def wildcard_resource?
  resources.include?(:*)
end

#wildcarded?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/sanction/attached_list.rb', line 38

def wildcarded?
  !!wildcard_member
end