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

Returns a new instance of ACLEntry.

Parameters:

  • principle (#to_s)

    principle for this ACL entry



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

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

Instance Attribute Details

#principleString (readonly)

The principle of this entry

Returns:

  • (String)

    principle of 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

Parameters:

  • entry (#to_s)

    string describing entry

  • kwargs (Hash)

    extra arguments

Returns:

  • (ACLEntry)

    entry generated by string

Raises:



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

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

Instance Method Details

#<=>(other) ⇒ Boolean

The comparison operator

Parameters:

  • other (#to_s)

    entry to compare against

Returns:

  • (Boolean)

    how entries compare



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

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

#eql?(other) ⇒ Boolean

Checks whether two ACLEntry objects are completely identical to each other

Parameters:

  • other (ACLEntry)

    entry to compare against

Returns:

  • (Boolean)

    whether same objects



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

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

#hashInteger

Generates a hash value for this object

Returns:

  • (Integer)

    hash value of object



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

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

#is_allow?Boolean

Is this an “allow” ACL entry

Returns:

  • (Boolean)

    is this an allow entry



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

def is_allow?
  true
end

#is_deny?Boolean

Is this a “deny” ACL entry

Returns:

  • (Boolean)

    is this a deny entry



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

def is_deny?
  !is_allow?
end

#match(principle:) ⇒ Boolean

Do the requested args match this ACL entry?

Returns:

  • (Boolean)

    does this match this entry



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

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

#to_sString

Convert object to string

Returns:

  • (String)

    the string describing this object



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

def to_s
  principle
end