Sha256: e24e27fd5251066236680ed5c47f8ca7f65ffaab4434e5f3d52b2adeb0ab6687

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 Bytes

Contents

module AbAdmin
  module Models
    module AttachmentFile

      extend ActiveSupport::Concern

      included do
        include ActionView::Helpers::NumberHelper
      end

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

      def human_name
        original_name.presence || data_file_name
      end

      def human_filesize
        number_to_human_size(data_file_size)
      end

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

      def as_json(options={})
        options.reverse_merge!(:methods => [:filename, :url, :preview_url, :thumb_url, :width, :height,
                                            :file_css_class, :human_filesize, :created_at])
        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ab_admin-0.1.2 lib/ab_admin/models/attachment_file.rb
ab_admin-0.1.1 lib/ab_admin/models/attachment_file.rb
ab_admin-0.1.0 lib/ab_admin/models/attachment_file.rb