Class: CaTissue::User

Inherits:
Object
  • Object
show all
Includes:
CaRuby::Resource::Unique, Person, Resource
Defined in:
lib/catissue/domain/user.rb,
lib/catissue/domain/uniquify.rb

Overview

The User domain class.

Instance Method Summary collapse

Methods included from Person

#name, #name=

Methods included from Resource

#database, included, #tolerant_match?

Methods included from Annotatable

#annotation_proxy, #create_proxy, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CaTissue::Annotatable

Instance Method Details

#role_idObject

caTissue alert - work-around for caTissue Bug #66 - Client missing CSException class et al. caTissue User class initializes roleId to “”, which triggers a client exception on subsequent getRoleId call. Use a private variable instead and bypass getRoleId.



16
17
18
19
20
21
22
# File 'lib/catissue/domain/user.rb', line 16

def role_id
  # TODO - uncomment following and get rid of @role_id i.v. when bug is fixed.
  #value = send(old_method)
  #return if value == ''
  #value.to_i
  @role_id
end

#role_id=(value) ⇒ Object

Sets the role id to the given value, which can be either a String or an Integer. An empty or zero value is converted to nil.

caTissue alert - caTissue API roleId is a String although the intended value domain is the integer csm_role.identifier.



29
30
31
32
33
34
35
36
37
38
# File 'lib/catissue/domain/user.rb', line 29

def role_id=(value)
  # value as an integer (nil is zero)
  value_i = value.to_i
  # set the Bug #66 work-around i.v.
  @role_id = value_i.zero? ? nil : value_i
  # value as a String (if non-nil)
  value_s = @role_id.to_s if @role_id
  # call Java with a String
  setRoleId(value_s)
end

#uniquifyObject

Makes this User’s login id and email address unique. The result is in the form name___suffix@test.com where:

  • name is the name prefix portion of the original email address

  • suffix is a unique number



77
78
79
80
# File 'lib/catissue/domain/uniquify.rb', line 77

def uniquify
  email = email_address ||= self. || return
  self. = self.email_address = uniquify_value(email[/[^@]+/]) + '@test.com'
end