Class: Sanction::Whitelist::NullNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sanction/whitelist/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
14
15
16
17
18
19
20
# File 'lib/sanction/whitelist/null_node.rb', line 11

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

#array_classObject Also known as: null_array_class



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

def array_class
  Sanction::Whitelist::NullList
end

#deny!Object



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

def deny!
  false
end

#permitted?Boolean

Returns:

  • (Boolean)


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

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

#persisted?Boolean

Returns:

  • (Boolean)


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

def persisted?
  false
end