Sha256: 7541712c8bb0327b60f1a5fdc0eec52e2d5fcfad5b437a696240c50224a04a7b
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'growi/client/model/growi_model' # Growi Attachment model class class GrowiAttachment < GrowiModelBase attr_reader :_id, :fileFormat, :fileName, :originalName, :filePath, :creator, :page, :__v, :createdAt, :fileSize, :url # Constractor # @param [Hash] Attachment model shown as hash # @todo Except running register method always called parse method. 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('Parameter _id is required.') end GrowiModelFactory.instance.register({ attachment_creator: Proc.new { |param| !param.nil? && param.is_a?(String) ? param : GrowiUser.new(param) }, attachment_createdAt: Proc.new { |date_str| !date_str.nil? && date_str != "" ? DateTime.parse(date_str) : "" }, }) maked_params = {} params.each do |k,v| maker = GrowiModelFactory.instance.maker('attachment_' + k.to_s) maked_params[k] = maker.call(v) end super(maked_params) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
growi-client-1.0.1 | lib/growi/client/model/growi_attachment.rb |
growi-client-1.0.0 | lib/growi/client/model/growi_attachment.rb |