Class: Verifica::Ace

Inherits:
Object
  • Object
show all
Defined in:
lib/verifica/ace.rb

Overview

Access Control Entry (ACE)

ACE is a minimal unit of the Access Control List (ACL) that defines whether or not a specific action is allowed for a particular Security Identifier (SID).

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sid, action, allow) ⇒ Ace

Creates a new Access Control Entry with immutable state



32
33
34
35
36
37
# File 'lib/verifica/ace.rb', line 32

def initialize(sid, action, allow)
  @sid = sid.dup.freeze
  @action = action.to_sym
  @allow = allow
  freeze
end

Instance Attribute Details

#actionSymbol (readonly)

Returns Action which is allowed or denied.



22
23
24
# File 'lib/verifica/ace.rb', line 22

def action
  @action
end

#sidString (readonly)

Returns Security Identifier (SID).



17
18
19
# File 'lib/verifica/ace.rb', line 17

def sid
  @sid
end

Instance Method Details

#==(other) ⇒ Object



64
65
66
# File 'lib/verifica/ace.rb', line 64

def ==(other)
  eql?(other)
end

#allow?Boolean

Returns true if the action is allowed.



42
43
44
# File 'lib/verifica/ace.rb', line 42

def allow?
  @allow
end

#deny?Boolean

Returns true if the action is denied.



49
50
51
# File 'lib/verifica/ace.rb', line 49

def deny?
  !allow?
end

#eql?(other) ⇒ Boolean



68
69
70
71
72
73
# File 'lib/verifica/ace.rb', line 68

def eql?(other)
  self.class == other.class &&
    @sid == other.sid &&
    @action == other.action &&
    @allow == other.allow?
end

#hashObject



75
76
77
# File 'lib/verifica/ace.rb', line 75

def hash
  [self.class, @sid, @action, @allow].hash
end

#to_hHash

Returns a new hash representing self.



56
57
58
# File 'lib/verifica/ace.rb', line 56

def to_h
  {sid: @sid, action: @action, allow: @allow}
end

#to_sObject



60
61
62
# File 'lib/verifica/ace.rb', line 60

def to_s
  to_h.to_s
end