Class: SDM::User

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

A User can connect to resources they are granted directly, or granted via roles.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, email: nil, first_name: nil, last_name: nil, suspended: nil, tags: nil) ⇒ User

Returns a new instance of User.



569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/models/porcelain.rb', line 569

def initialize(
  id: nil,
  email: nil,
  first_name: nil,
  last_name: nil,
  suspended: nil,
  tags: nil
)
  if id != nil
    @id = id
  end
  if email != nil
    @email = email
  end
  if first_name != nil
    @first_name = first_name
  end
  if last_name != nil
    @last_name = last_name
  end
  if suspended != nil
    @suspended = suspended
  end
  if tags != nil
    @tags = tags
  end
end

Instance Attribute Details

#emailObject

The User’s email address. Must be unique.



559
560
561
# File 'lib/models/porcelain.rb', line 559

def email
  @email
end

#first_nameObject

The User’s first name.



561
562
563
# File 'lib/models/porcelain.rb', line 561

def first_name
  @first_name
end

#idObject

Unique identifier of the User.



557
558
559
# File 'lib/models/porcelain.rb', line 557

def id
  @id
end

#last_nameObject

The User’s last name.



563
564
565
# File 'lib/models/porcelain.rb', line 563

def last_name
  @last_name
end

#suspendedObject

The User’s suspended state.



565
566
567
# File 'lib/models/porcelain.rb', line 565

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



567
568
569
# File 'lib/models/porcelain.rb', line 567

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



597
598
599
600
601
602
603
# File 'lib/models/porcelain.rb', line 597

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end