Class: CrowiAttachment

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

Overview

Crowi Attachment model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ CrowiAttachment

TODO:

Except running register method always called parse method.

Constractor

Parameters:

  • Attachment (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
33
# File 'lib/crowi/client/model/crowi_attachment.rb', line 11

def initialize(params = {})
  init_params = {
    _id: nil, fileFormat: '', fileName: '', originalName: '', filePath: nil,
    creator: nil, page: '', __v: 0, createdAt: '', fileSize: 0, url: ''
  }

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

  CrowiModelFactory.instance.register({
    attachment_creator:   Proc.new { |param| param != nil && param.is_a?(String) ? param : CrowiUser.new(param) },
    attachment_createdAt: Proc.new { |date_str|
                            date_str != nil && DateTime.parse(date_str) },
  })
  maked_params = {}
  params.each do |k,v|
    maker = CrowiModelFactory.instance.maker('attachment_' + 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.



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

def __v
  @__v
end

#_idObject (readonly)

Returns the value of attribute _id.



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

def _id
  @_id
end

#createdAtObject (readonly)

Returns the value of attribute createdAt.



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

def createdAt
  @createdAt
end

#creatorObject (readonly)

Returns the value of attribute creator.



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

def creator
  @creator
end

#fileFormatObject (readonly)

Returns the value of attribute fileFormat.



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

def fileFormat
  @fileFormat
end

#fileNameObject (readonly)

Returns the value of attribute fileName.



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

def fileName
  @fileName
end

#filePathObject (readonly)

Returns the value of attribute filePath.



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

def filePath
  @filePath
end

#fileSizeObject (readonly)

Returns the value of attribute fileSize.



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

def fileSize
  @fileSize
end

#originalNameObject (readonly)

Returns the value of attribute originalName.



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

def originalName
  @originalName
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end