Class: GrowiPage

Inherits:
GrowiModelBase show all
Defined in:
lib/growi/client/model/growi_page.rb

Overview

Growi 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 = {}) ⇒ GrowiPage

TODO:

Except running register method always called parse method.

Constract

Parameters:

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

    Prameters data show as Hash



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
51
52
# File 'lib/growi/client/model/growi_page.rb', line 24

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: ''
  }
  params = init_params.merge(params.map { |k,v| [k.to_sym, v] }.to_h)
  if (params[:_id].nil?)
    raise ArgumentError.new('Parameter _id is required.')
  end

  # @note Parameters lastUpdateUser and creator have two patterns ID only or Object.
  GrowiModelFactory.instance.register({
    page_updatedAt:      Proc.new { |str| !str.nil? && str != "" ? DateTime.parse(str) : "" },
    page_lastUpdateUser: Proc.new { |param| !param.nil? && param.is_a?(String) ? param : GrowiUser.new(param) },
    page_creator:        Proc.new { |param| !param.nil? && param.is_a?(String) ? param : GrowiUser.new(param) },
    page_createdAt:      Proc.new { |str| !str.nil? && str != "" ? DateTime.parse(str) : "" },

    # revision が文字列のみ(IDだけの場合)であれば _id のみを格納し、ハッシュ化されていればすべて読み込む
    page_revision:       Proc.new { |param| !param.nil? && GrowiPageRevision.new(param.is_a?(String) ? { _id: param } : param) },
  })
  maked_params = {}
  params.each do |k,v|
    maker = GrowiModelFactory.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/growi/client/model/growi_page.rb', line 15

def __v
  @__v
end

#_idObject (readonly)

Returns the value of attribute _id.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def _id
  @_id
end

#commentCountObject (readonly)

Returns the value of attribute commentCount.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def commentCount
  @commentCount
end

#createdAtObject (readonly)

Returns the value of attribute createdAt.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def createdAt
  @createdAt
end

#creatorObject (readonly)

Returns the value of attribute creator.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def creator
  @creator
end

#extendedObject (readonly)

Returns the value of attribute extended.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def extended
  @extended
end

#grantObject (readonly)

Returns the value of attribute grant.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def grant
  @grant
end

#grantedUsersObject (readonly)

Returns the value of attribute grantedUsers.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def grantedUsers
  @grantedUsers
end

#hasDraftOnHackmdObject (readonly)

Returns the value of attribute hasDraftOnHackmd.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def hasDraftOnHackmd
  @hasDraftOnHackmd
end

#lastUpdateUserObject (readonly)

Returns the value of attribute lastUpdateUser.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def lastUpdateUser
  @lastUpdateUser
end

#likerObject (readonly)

Returns the value of attribute liker.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def liker
  @liker
end

#pageIdOnHackmdObject (readonly)

Returns the value of attribute pageIdOnHackmd.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def pageIdOnHackmd
  @pageIdOnHackmd
end

#pathObject (readonly)

Returns the value of attribute path.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def path
  @path
end

#redirectToObject (readonly)

Returns the value of attribute redirectTo.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def redirectTo
  @redirectTo
end

#revisionObject (readonly)

Returns the value of attribute revision.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def revision
  @revision
end

#revisionHackmdSyncedObject (readonly)

Returns the value of attribute revisionHackmdSynced.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def revisionHackmdSynced
  @revisionHackmdSynced
end

#seenUsersObject (readonly)

Returns the value of attribute seenUsers.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def seenUsers
  @seenUsers
end

#statusObject (readonly)

Returns the value of attribute status.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def status
  @status
end

#updatedAtObject (readonly)

Returns the value of attribute updatedAt.



15
16
17
# File 'lib/growi/client/model/growi_page.rb', line 15

def updatedAt
  @updatedAt
end