Class: PlatformSdk::PencilSpaces::Models::UserWithRole

Inherits:
Object
  • Object
show all
Defined in:
lib/platform_sdk/pencil_spaces/models/user_with_role.rb

Constant Summary collapse

VALID_ROLES =
%i[host participant].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, user_role_in_space = nil) ⇒ UserWithRole

Returns a new instance of UserWithRole.



11
12
13
14
15
16
17
# File 'lib/platform_sdk/pencil_spaces/models/user_with_role.rb', line 11

def initialize(user_id, user_role_in_space = nil)
  @user_id = user_id
  return unless user_role_in_space

  validate_role!(user_role_in_space)
  @role = user_role_in_space
end

Instance Attribute Details

#roleObject

Returns the value of attribute role.



7
8
9
# File 'lib/platform_sdk/pencil_spaces/models/user_with_role.rb', line 7

def role
  @role
end

#user_idObject

Returns the value of attribute user_id.



7
8
9
# File 'lib/platform_sdk/pencil_spaces/models/user_with_role.rb', line 7

def user_id
  @user_id
end

Instance Method Details

#as_jsonObject



19
20
21
22
23
24
25
26
27
# File 'lib/platform_sdk/pencil_spaces/models/user_with_role.rb', line 19

def as_json
  json = {}
  instance_variables.each do |var|
    key = var.to_s.delete("@")
    key = "userId" if key == "user_id"
    json[key] = instance_variable_get(var).to_s if instance_variable_get(var)
  end
  json
end