Class: OneLogin::Api::Models::Privilege
- Inherits:
-
Object
- Object
- OneLogin::Api::Models::Privilege
- Defined in:
- lib/onelogin/api/models/privilege.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#statements ⇒ Object
Returns the value of attribute statements.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #from_data(data) ⇒ Object
- #from_values(id, name, version, statements) ⇒ Object
- #get_valid_actions ⇒ Object
-
#initialize(*args) ⇒ Privilege
constructor
A new instance of Privilege.
Constructor Details
#initialize(*args) ⇒ Privilege
Returns a new instance of Privilege.
11 12 13 14 15 16 17 |
# File 'lib/onelogin/api/models/privilege.rb', line 11 def initialize(*args) if args.length == 1 self.from_data(args[0]) else self.from_values(args[0],args[1], args[2], args[3]) end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/onelogin/api/models/privilege.rb', line 9 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/onelogin/api/models/privilege.rb', line 9 def name @name end |
#statements ⇒ Object
Returns the value of attribute statements.
9 10 11 |
# File 'lib/onelogin/api/models/privilege.rb', line 9 def statements @statements end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/onelogin/api/models/privilege.rb', line 9 def version @version end |
Instance Method Details
#from_data(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/onelogin/api/models/privilege.rb', line 19 def from_data(data) @id = data['id'] @name = data['name'] @version = data['privilege']['Version'] statements_data = data['privilege']['Statement'] @statements = [] for statement_data in statements_data @statements << Statement.new(statement_data) end end |
#from_values(id, name, version, statements) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/onelogin/api/models/privilege.rb', line 30 def from_values(id, name, version, statements) @id = id @name = name @version = version @statements = [] for statement in statements if statement.instance_of?(Statement) @statements << statement elsif statement.instance_of?(Hash) && statement.has_key?('Effect') && statement.has_key?('Action') && statement.has_key?('Scope') @statements << Statement.new(statement['Effect'], statement['Action'], statement['Scope']) end end end |
#get_valid_actions ⇒ Object
44 45 46 47 |
# File 'lib/onelogin/api/models/privilege.rb', line 44 def get_valid_actions return Constants.VALID_ACTIONS end |