Sha256: b8eb63c9a1f44a56c4c4bd18029c3bdda5bfa49c30f8400c4df04c4427b9ca15

Contents?: true

Size: 852 Bytes

Versions: 6

Compression:

Stored size: 852 Bytes

Contents

module Uploadcare
  module Rails
    class File < Uploadcare::Api::File
      def url(operations = nil)
        cdn_url unless operations
        cdn_url + prepared_operations(operations)
      end

      def prepared_operations(operations)
        Uploadcare::Rails::Operations.new(operations).to_s
      end

      # construct image tag for file
      def image(operations = nil)
        image_tag(url(operations))
      end

      # override default to string method
      # instead of string representation of object it will return simple cdn url of a file
      def to_s
        cdn_url
      end

      def to_builder
        marshal_dump
      end

      def to_json
        marshal_dump
      end

      def as_json(_options = {})
        marshal_dump
      end

      def marshal_dump
        @table.stringify_keys
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uploadcare-rails-1.2.1 lib/uploadcare/rails/objects/file.rb
uploadcare-rails-1.2.0 lib/uploadcare/rails/objects/file.rb
uploadcare-rails-1.2.0.pre.alpha3 lib/uploadcare/rails/objects/file.rb
uploadcare-rails-1.2.0.pre.alpha lib/uploadcare/rails/objects/file.rb
uploadcare-rails-1.1.1 lib/uploadcare/rails/objects/file.rb
uploadcare-rails-1.1.0 lib/uploadcare/rails/objects/file.rb