Class: Sanction::Whitelist::Node

Inherits:
Node
  • Object
show all
Defined in:
lib/sanction/whitelist/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
# File 'lib/sanction/whitelist/node.rb', line 10

def allow!
  false
end

#array_classObject



37
38
39
# File 'lib/sanction/whitelist/node.rb', line 37

def array_class
  Sanction::Whitelist::List
end

#blacklist?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/sanction/whitelist/node.rb', line 29

def blacklist?
  false
end

#deny!Object



18
19
20
21
22
23
# File 'lib/sanction/whitelist/node.rb', line 18

def deny!
  @parent.resources << type
  @parent.resources.uniq!
  unlink
  true
end

#modeObject



33
34
35
# File 'lib/sanction/whitelist/node.rb', line 33

def mode
  'whitelist'
end

#null_array_classObject



41
42
43
# File 'lib/sanction/whitelist/node.rb', line 41

def null_array_class
  Sanction::Whitelist::NullList
end

#permitted?Boolean

Returns:

  • (Boolean)


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

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

#scopeObject



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

def scope
  permitted? ? super : []
end

#whitelist?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/sanction/whitelist/node.rb', line 25

def whitelist?
  true
end