Sha256: f4707dc9f5bb34a52c68135df39fd5c485cb1356d9a451c07cd8191071ea1f6c

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'resync'
require_relative 'client_delegator'

module Resync
  class Client
    module Mixins
      # A downloadable resource or link.
      module Downloadable
        prepend ClientDelegator

        # Delegates to {Client#get_and_parse} to get the contents of
        # +:uri+ as a ResourceSync document
        def get_and_parse # rubocop:disable Style/AccessorMethodName
          client.get_and_parse(uri)
        end

        # Delegates to {Client#get} to get the contents of this +:uri+
        def get # rubocop:disable Style/AccessorMethodName
          client.get(uri)
        end

        # Delegates to {Client#download_to_temp_file} to download the
        # contents of +:uri+ to a file.
        def download_to_temp_file # rubocop:disable Style/AccessorMethodName
          client.download_to_temp_file(uri)
        end

        # Delegates to {Client#download_to_file} to download the
        # contents of +:uri+ to the specified path.
        # @param path [String] the path to download to
        def download_to_file(path)
          client.download_to_file(uri: uri, path: path)
        end
      end
    end
  end

  class Link
    prepend Client::Mixins::Downloadable
  end

  class Resource
    prepend Client::Mixins::Downloadable
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resync-client-0.3.0 lib/resync/client/mixins/downloadable.rb
resync-client-0.2.5 lib/resync/client/mixins/downloadable.rb
resync-client-0.2.4 lib/resync/client/mixins/downloadable.rb