Class: Sanction::Blacklist::NullNode

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

Instance Attribute Summary

Attributes inherited from Node

#id, #type

Instance Method Summary collapse

Methods inherited from Node

#blacklist?, #mode, #scope, #whitelist?

Methods inherited from Node

#[], #add_scope, #add_subject, #change_type!, #children, #children?, #find, #has_scope?, #id?, #initialize, #mode, #remove_scope, #resources, #resources=, #scope, #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



11
12
13
# File 'lib/sanction/blacklist/null_node.rb', line 11

def allow!
  false
end

#array_classObject Also known as: null_array_class



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

def array_class
  Sanction::Blacklist::NullList
end

#deny!Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/sanction/blacklist/null_node.rb', line 15

def deny!
  ancestors.reject(&:persisted?).each(&:deny!)
  @parent = root.find(@parent.type, @parent.id) unless @parent.persisted?
  @parent.resources << type
  @parent.resources.uniq!
  @parent.add_subject({
    id:   id,
    type: type
  })
end

#permitted?Boolean

Returns:

  • (Boolean)


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

def permitted?
  a = ancestors.reject(&:root?).map(&:permitted?)
  a << true 
  a.all?
end

#persisted?Boolean

Returns:

  • (Boolean)


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

def persisted?
  false
end