Module: AbAdmin::Models::AttachmentFile

Extended by:
ActiveSupport::Concern
Included in:
AttachmentFile
Defined in:
lib/ab_admin/models/attachment_file.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object


24
25
26
27
# File 'lib/ab_admin/models/attachment_file.rb', line 24

def as_json(options={})
  options.reverse_merge!(methods: [:filename, :url, :is_image, :file_css_class, :human_filesize, :created_at])
  super
end

#file_css_classObject


12
13
14
# File 'lib/ab_admin/models/attachment_file.rb', line 12

def file_css_class
  MIME::Type.new(data_content_type).try(:sub_type).gsub('.', '_')
end

#human_dateObject


20
21
22
# File 'lib/ab_admin/models/attachment_file.rb', line 20

def human_date
  I18n.l(created_at, format: '%d %B %Y')
end

#human_filesizeObject


16
17
18
# File 'lib/ab_admin/models/attachment_file.rb', line 16

def human_filesize
  number_to_human_size(data_file_size)
end