Class: CrowiUser

Inherits:
CrowiModelBase show all
Defined in:
lib/crowi/client/model/crowi_user.rb

Overview

Crowi User model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ CrowiUser

TODO:

Except running register method always called parse method.

Constractor

Parameters:

  • User (Hash)

    model shown as hash



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/crowi/client/model/crowi_user.rb', line 11

def initialize(params = {})
  init_params = {
    _id: nil, email: nil, username: nil, name: '',
    admin: false, createdAt: '', status: 0, lang: '', isGravatarEnabled: false
  }

  params = init_params.merge(params.map { |k,v| [k.to_sym, v] }.to_h)
  if (params[:_id] == nil || params[:email] == nil || params[:username] == nil)
    raise ArgumentError.new('Parameters id and email and name are required.')
  end

  CrowiModelFactory.instance.register({
    user_createdAt: Proc.new { |date_str|
                      date_str != nil && DateTime.parse(date_str) },
  })
  maked_params = {}
  params.each do |k,v|
    maker = CrowiModelFactory.instance.maker('user_' + k.to_s)
    maked_params[k] = maker.call(v)
  end
  super(maked_params)
end

Instance Attribute Details

#_idObject (readonly)

Returns the value of attribute _id.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def _id
  @_id
end

#adminObject (readonly)

Returns the value of attribute admin.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def admin
  @admin
end

#createdAtObject (readonly)

Returns the value of attribute createdAt.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def createdAt
  @createdAt
end

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def email
  @email
end

#isGravatarEnabledObject (readonly)

Returns the value of attribute isGravatarEnabled.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def isGravatarEnabled
  @isGravatarEnabled
end

#langObject (readonly)

Returns the value of attribute lang.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def lang
  @lang
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def status
  @status
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/crowi/client/model/crowi_user.rb', line 5

def username
  @username
end