Class: Sanction::Blacklist::Node

Inherits:
Node
  • Object
show all
Defined in:
lib/sanction/blacklist/node.rb

Direct Known Subclasses

NullNode

Instance Attribute Summary

Attributes inherited from Node

#id, #type

Instance Method Summary collapse

Methods inherited from Node

#[], #add_scope, #add_subject, #change_type!, #children, #children?, #find, #has_scope?, #id?, #initialize, #persisted?, #remove_scope, #resources, #resources=, #scope=, #to_hash, #type?, #wildcarded?

Methods included from Tree

#ancestors, #children, #depth, #descendants, #graft, #has_children?, #height, #leaf?, #only_child?, #parent, #prune, #root, #root?, #siblings, #unlink, #walk

Constructor Details

This class inherits a constructor from Sanction::Node

Instance Method Details

#allow!Object



10
11
12
13
14
# File 'lib/sanction/blacklist/node.rb', line 10

def allow!
  @parent.resources.reject! {|x| x == type } unless @parent[type].count > 1
  unlink
  true
end

#array_classObject



36
37
38
# File 'lib/sanction/blacklist/node.rb', line 36

def array_class
  Sanction::Blacklist::List
end

#blacklist?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/sanction/blacklist/node.rb', line 28

def blacklist?
  true
end

#deny!Object



20
21
22
# File 'lib/sanction/blacklist/node.rb', line 20

def deny!
  false
end

#modeObject



32
33
34
# File 'lib/sanction/blacklist/node.rb', line 32

def mode
  'blacklist'
end

#null_array_classObject



40
41
42
# File 'lib/sanction/blacklist/node.rb', line 40

def null_array_class
  Sanction::Blacklist::NullList
end

#permitted?Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/sanction/blacklist/node.rb', line 5

def permitted?
  super
  root? ? true : (@parent[type].permitted? && @parent[type].allowed_ids.include?(id))
end

#scopeObject



16
17
18
# File 'lib/sanction/blacklist/node.rb', line 16

def scope
  permitted? ? super : []
end

#whitelist?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/sanction/blacklist/node.rb', line 24

def whitelist?
  false
end