Class: NewStoreApi::Permission

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/permission.rb

Overview

List of all available system permissions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#applicationApplicationEnum

Abbreviation of the application this permission belongs to.

Returns:



14
15
16
# File 'lib/new_store_api/models/permission.rb', line 14

def application
  @application
end

#childrenArray[Permission]

Nested list of child permissions.

Returns:



18
19
20
# File 'lib/new_store_api/models/permission.rb', line 18

def children
  @children
end

#nameString

Name of the permission.

Returns:

  • (String)


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

.namesObject

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

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/new_store_api/models/permission.rb', line 41

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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