Class: Seira::Teleport::RoleRequirement
- Inherits:
-
Object
- Object
- Seira::Teleport::RoleRequirement
- Includes:
- Comparable
- Defined in:
- lib/seira/teleport/role_requirements.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(requirement) ⇒ RoleRequirement
constructor
A new instance of RoleRequirement.
- #matches?(category, command) ⇒ Boolean
Constructor Details
#initialize(requirement) ⇒ RoleRequirement
Returns a new instance of RoleRequirement.
8 9 10 11 12 13 |
# File 'lib/seira/teleport/role_requirements.rb', line 8 def initialize(requirement) @requirement = requirement @category = requirement['category'] @commands = requirement['commands'] @roles = requirement['roles'] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
6 7 8 |
# File 'lib/seira/teleport/role_requirements.rb', line 6 def category @category end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
6 7 8 |
# File 'lib/seira/teleport/role_requirements.rb', line 6 def commands @commands end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
6 7 8 |
# File 'lib/seira/teleport/role_requirements.rb', line 6 def roles @roles end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/seira/teleport/role_requirements.rb', line 19 def <=>(other) raise ArgumentError, 'Cannot compare different categories' if category != other.category if commands.nil? return -1 elsif other.commands.nil? return 1 end commands.length <=> other.commands.length end |
#matches?(category, command) ⇒ Boolean
15 16 17 |
# File 'lib/seira/teleport/role_requirements.rb', line 15 def matches?(category, command) @category == category && command_matches?(command) end |