Class: CrowiPage

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

Overview

Crowi Page model class

Constant Summary collapse

GRANT_PUBLIC =
1.freeze
GRANT_RESTRICTED =
2.freeze
GRANT_SPECIFIED =
3.freeze
GRANT_OWNER =
4.freeze
STATUS_WIP =
'wip'.freeze
STATUS_PUBLISHED =
'published'.freeze
STATUS_DELETED =
'deleted'.freeze
STATUS_DEPRECATED =
'deprecated'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ CrowiPage

TODO:

Except running register method always called parse method.

Constract

Parameters:

  • params (Hash) (defaults to: {})

    Prameters data show as Hash



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/crowi/client/model/crowi_page.rb', line 23

def initialize(params = {})
  init_params = {
    _id: '', redirectTo: nil, updatedAt: '', lastUpdateUser: '',
    creator: nil, path: nil, __v: 0, revision: nil, createdAt: '',
    commentCount: 0, seenUsers: [], liker: [], grantedUsers: [],
    grant: 0, status: '', id: ''
  }

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

  # @note Parameters lastUpdateUser and creator have two patterns ID only or Object.
  CrowiModelFactory.instance.register({
    page_updatedAt:      Proc.new { |str| str != nil && DateTime.parse(str) },
    page_lastUpdateUser: Proc.new { |param| param != nil && param.is_a?(String) ? param : CrowiUser.new(param) },
    page_creator:        Proc.new { |param| param != nil && param.is_a?(String) ? param : CrowiUser.new(param) },
    page_createdAt:      Proc.new { |str| str != nil && DateTime.parse(str) },
    page_revision:       Proc.new { |param| param != nil && CrowiPageRevision.new(param) },
  })
  maked_params = {}
  params.each do |k,v|
    maker = CrowiModelFactory.instance.maker('page_' + k.to_s)
    maked_params[k] = maker.call(v)
  end
  super(maked_params)
end

Instance Attribute Details

#__vObject (readonly)

Returns the value of attribute __v.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def __v
  @__v
end

#_idObject (readonly)

Returns the value of attribute _id.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def _id
  @_id
end

#commentCountObject (readonly)

Returns the value of attribute commentCount.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def commentCount
  @commentCount
end

#createdAtObject (readonly)

Returns the value of attribute createdAt.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def createdAt
  @createdAt
end

#creatorObject (readonly)

Returns the value of attribute creator.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def creator
  @creator
end

#grantObject (readonly)

Returns the value of attribute grant.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def grant
  @grant
end

#grantedUsersObject (readonly)

Returns the value of attribute grantedUsers.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def grantedUsers
  @grantedUsers
end

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def id
  @id
end

#lastUpdateUserObject (readonly)

Returns the value of attribute lastUpdateUser.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def lastUpdateUser
  @lastUpdateUser
end

#likerObject (readonly)

Returns the value of attribute liker.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def liker
  @liker
end

#pathObject (readonly)

Returns the value of attribute path.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def path
  @path
end

#redirectToObject (readonly)

Returns the value of attribute redirectTo.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def redirectTo
  @redirectTo
end

#revisionObject (readonly)

Returns the value of attribute revision.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def revision
  @revision
end

#seenUsersObject (readonly)

Returns the value of attribute seenUsers.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def seenUsers
  @seenUsers
end

#statusObject (readonly)

Returns the value of attribute status.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def status
  @status
end

#updatedAtObject (readonly)

Returns the value of attribute updatedAt.



15
16
17
# File 'lib/crowi/client/model/crowi_page.rb', line 15

def updatedAt
  @updatedAt
end