Class: OodSupport::ACLEntry

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ood_support/acl_entry.rb

Overview

A helper object that defines a generic ACL entry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(principle:) ⇒ ACLEntry


20
21
22
# File 'lib/ood_support/acl_entry.rb', line 20

def initialize(principle:)
  @principle = principle.to_s
end

Instance Attribute Details

#principleString (readonly)

The principle of this entry


8
9
10
# File 'lib/ood_support/acl_entry.rb', line 8

def principle
  @principle
end

Class Method Details

.parse(entry, **kwargs) ⇒ ACLEntry

Generate an entry by parsing a string

Raises:


15
16
17
# File 'lib/ood_support/acl_entry.rb', line 15

def self.parse(entry, **kwargs)
  new(parse_entry(entry).merge(kwargs))
end

Instance Method Details

#<=>(other) ⇒ Boolean

The comparison operator


52
53
54
# File 'lib/ood_support/acl_entry.rb', line 52

def <=>(other)
  to_s <=> other
end

#eql?(other) ⇒ Boolean

Checks whether two ACLEntry objects are completely identical to each other


60
61
62
# File 'lib/ood_support/acl_entry.rb', line 60

def eql?(other)
  self.class == other.class && self == other
end

#hashFixnum

Generates a hash value for this object


66
67
68
# File 'lib/ood_support/acl_entry.rb', line 66

def hash
  [self.class, to_s].hash
end

#is_allow?Boolean

Is this an “allow” ACL entry


26
27
28
# File 'lib/ood_support/acl_entry.rb', line 26

def is_allow?
  true
end

#is_deny?Boolean

Is this a “deny” ACL entry


32
33
34
# File 'lib/ood_support/acl_entry.rb', line 32

def is_deny?
  !is_allow?
end

#match(principle:) ⇒ Boolean

Do the requested args match this ACL entry?


39
40
41
# File 'lib/ood_support/acl_entry.rb', line 39

def match(principle:)
  self.principle == principle
end

#to_sString

Convert object to string


45
46
47
# File 'lib/ood_support/acl_entry.rb', line 45

def to_s
  principle
end