Class: WorkOS::Role

Inherits:
Object
  • Object
show all
Includes:
HashProvider
Defined in:
lib/workos/role.rb

Overview

The Role class provides a lightweight wrapper around a WorkOS Role resource. This class is not meant to be instantiated in user space, and is instantiated internally but exposed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashProvider

#to_h

Constructor Details

#initialize(json) ⇒ Role

Returns a new instance of Role.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/workos/role.rb', line 12

def initialize(json)
  hash = JSON.parse(json, symbolize_names: true)

  @id = hash[:id]
  @name = hash[:name]
  @slug = hash[:slug]
  @description = hash[:description]
  @type = hash[:type]
  @created_at = hash[:created_at]
  @updated_at = hash[:updated_at]
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



10
11
12
# File 'lib/workos/role.rb', line 10

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



10
11
12
# File 'lib/workos/role.rb', line 10

def description
  @description
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/workos/role.rb', line 10

def id
  @id
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/workos/role.rb', line 10

def name
  @name
end

#slugObject

Returns the value of attribute slug.



10
11
12
# File 'lib/workos/role.rb', line 10

def slug
  @slug
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/workos/role.rb', line 10

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



10
11
12
# File 'lib/workos/role.rb', line 10

def updated_at
  @updated_at
end

Instance Method Details

#to_jsonObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/workos/role.rb', line 24

def to_json(*)
  {
    id: id,
    name: name,
    slug: slug,
    description: description,
    type: type,
    created_at: created_at,
    updated_at: updated_at,
  }
end