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


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

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
# 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

Parameters:

  • other (#to_s)

    entry to compare against

Returns:

  • (Boolean)

    how entries compare


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

Parameters:

  • other (ACLEntry)

    entry to compare against

Returns:

  • (Boolean)

    whether same objects


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

Returns:

  • (Fixnum)

    hash value of 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

Returns:

  • (Boolean)

    is this an allow 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

Returns:

  • (Boolean)

    is this a deny 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?

Returns:

  • (Boolean)

    does this match this 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

Returns:

  • (String)

    the string describing this object


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

def to_s
  principle
end