Class: NewStoreApi::Permission
- Defined in:
- lib/new_store_api/models/permission.rb
Overview
List of all available system permissions.
Instance Attribute Summary collapse
-
#application ⇒ ApplicationEnum
Abbreviation of the application this permission belongs to.
-
#children ⇒ Array[Permission]
Nested list of child permissions.
-
#name ⇒ String
Name of the permission.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(application = nil, name = nil, children = SKIP) ⇒ Permission
constructor
A new instance of Permission.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(application = nil, name = nil, children = SKIP) ⇒ Permission
Returns a new instance of Permission.
45 46 47 48 49 |
# File 'lib/new_store_api/models/permission.rb', line 45 def initialize(application = nil, name = nil, children = SKIP) @application = application @children = children unless children == SKIP @name = name end |
Instance Attribute Details
#application ⇒ ApplicationEnum
Abbreviation of the application this permission belongs to.
14 15 16 |
# File 'lib/new_store_api/models/permission.rb', line 14 def application @application end |
#children ⇒ Array[Permission]
Nested list of child permissions.
18 19 20 |
# File 'lib/new_store_api/models/permission.rb', line 18 def children @children end |
#name ⇒ String
Name of the permission.
22 23 24 |
# File 'lib/new_store_api/models/permission.rb', line 22 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_store_api/models/permission.rb', line 52 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. application = hash.key?('application') ? hash['application'] : nil name = hash.key?('name') ? hash['name'] : nil # Parameter is an array, so we need to iterate through it children = nil unless hash['children'].nil? children = [] hash['children'].each do |structure| children << (Permission.from_hash(structure) if structure) end end children = SKIP unless hash.key?('children') # Create object from extracted values. Permission.new(application, name, children) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/new_store_api/models/permission.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['application'] = 'application' @_hash['children'] = 'children' @_hash['name'] = 'name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/new_store_api/models/permission.rb', line 41 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 |
# File 'lib/new_store_api/models/permission.rb', line 34 def self.optionals %w[ children ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
82 83 84 85 86 |
# File 'lib/new_store_api/models/permission.rb', line 82 def inspect class_name = self.class.name.split('::').last "<#{class_name} application: #{@application.inspect}, children: #{@children.inspect}, name:"\ " #{@name.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
76 77 78 79 |
# File 'lib/new_store_api/models/permission.rb', line 76 def to_s class_name = self.class.name.split('::').last "<#{class_name} application: #{@application}, children: #{@children}, name: #{@name}>" end |