Class: NewStoreApi::RoleItem
- Defined in:
- lib/new_store_api/models/role_item.rb
Overview
Needed for granting permissions per group not individually.
Instance Attribute Summary collapse
-
#id ⇒ String
Identifier of the role.
-
#is_readonly ⇒ TrueClass | FalseClass
The role is read-only and not editable.
-
#name ⇒ String
Name of the role.
-
#updated_at ⇒ DateTime
Name of the role.
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(id = nil, name = nil, is_readonly = SKIP, updated_at = SKIP) ⇒ RoleItem
constructor
A new instance of RoleItem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_updated_at ⇒ Object
-
#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(id = nil, name = nil, is_readonly = SKIP, updated_at = SKIP) ⇒ RoleItem
Returns a new instance of RoleItem.
52 53 54 55 56 57 |
# File 'lib/new_store_api/models/role_item.rb', line 52 def initialize(id = nil, name = nil, is_readonly = SKIP, updated_at = SKIP) @id = id @is_readonly = is_readonly unless is_readonly == SKIP @name = name @updated_at = updated_at unless updated_at == SKIP end |
Instance Attribute Details
#id ⇒ String
Identifier of the role.
15 16 17 |
# File 'lib/new_store_api/models/role_item.rb', line 15 def id @id end |
#is_readonly ⇒ TrueClass | FalseClass
The role is read-only and not editable.
19 20 21 |
# File 'lib/new_store_api/models/role_item.rb', line 19 def is_readonly @is_readonly end |
#name ⇒ String
Name of the role.
23 24 25 |
# File 'lib/new_store_api/models/role_item.rb', line 23 def name @name end |
#updated_at ⇒ DateTime
Name of the role.
27 28 29 |
# File 'lib/new_store_api/models/role_item.rb', line 27 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/new_store_api/models/role_item.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil name = hash.key?('name') ? hash['name'] : nil is_readonly = hash.key?('is_readonly') ? hash['is_readonly'] : SKIP updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end # Create object from extracted values. RoleItem.new(id, name, is_readonly, updated_at) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/new_store_api/models/role_item.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['is_readonly'] = 'is_readonly' @_hash['name'] = 'name' @_hash['updated_at'] = 'updated_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
48 49 50 |
# File 'lib/new_store_api/models/role_item.rb', line 48 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 |
# File 'lib/new_store_api/models/role_item.rb', line 40 def self.optionals %w[ is_readonly updated_at ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
92 93 94 95 96 |
# File 'lib/new_store_api/models/role_item.rb', line 92 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, is_readonly: #{@is_readonly.inspect}, name:"\ " #{@name.inspect}, updated_at: #{@updated_at.inspect}>" end |
#to_custom_updated_at ⇒ Object
80 81 82 |
# File 'lib/new_store_api/models/role_item.rb', line 80 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
85 86 87 88 89 |
# File 'lib/new_store_api/models/role_item.rb', line 85 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, is_readonly: #{@is_readonly}, name: #{@name}, updated_at:"\ " #{@updated_at}>" end |