Module: Resync

Defined in:
lib/resync/client/mixins/downloadable.rb,
lib/resync/client.rb,
lib/resync/extensions.rb,
lib/resync/client/version.rb,
lib/resync/client/http_helper.rb,
lib/resync/client/zip/bitstream.rb,
lib/resync/client/zip/zip_package.rb,
lib/resync/client/zip/zip_packages.rb,
lib/resync/client/mixins/zipped_resource.rb,
lib/resync/client/mixins/client_delegator.rb,
lib/resync/client/mixins/bitstream_resource.rb,
lib/resync/client/mixins/link_client_delegate.rb,
lib/resync/client/mixins/zipped_resource_list.rb,
lib/resync/client/mixins/bitstream_resource_list.rb,
lib/resync/client/mixins/resource_client_delegate.rb

Overview

A resource container that is capable of providing those resources with a Client

Defined Under Namespace

Classes: Augmented, BaseResourceList, ChangeDump, ChangeDumpManifest, Client, Link, Resource, ResourceDump, ResourceDumpManifest

Instance Attribute Summary collapse

Instance Attribute Details

#client_delegate ⇒ #client

Returns The client provider.

Returns:

  • (#client) —

    The client provider.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/resync/client/mixins/client_delegator.rb', line 8

module Resync
  class Client
    module Mixins
      module ClientDelegator
        attr_accessor :client_delegate

        def client
          client_delegate.client
        end

        # Creates a one-off delegate wrapper around the specified {Client}
        # @param value [Client] the client
        def client=(value)
          @client_delegate = ClientDelegate.new(value)
        end

        # Minimal 'delegate' wrapper around a specified {Client}
        class ClientDelegate
          # @return [#client] the client
          attr_reader :client

          # Creates a new {ClientDelegate} wrapping the specified {Client}
          # @param client The client to delegate to
          def initialize(client)
            @client = client
          end
        end
      end
    end
  end
end

#zip_package ⇒ ZipPackage

Returns the package.

Returns:

  • (ZipPackage) —

    the package.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/resync/client/mixins/bitstream_resource_list.rb', line 9

module Resync
  class Client
    module Mixins
      module BitstreamResourceList
        attr_accessor :zip_package

        # Makes each provided resource a {BitstreamResource}
        # @param value [Array<Resource>] the resources for this list
        def resources=(value)
          super
          resources.each do |r|
            class << r
              prepend BitstreamResource
            end
            r.zip_package_delegate = self
          end
        end
      end
    end
  end
end

#zip_package_delegate ⇒ ZipPackage

Returns the provider of the containing package, e.g. its manifest.

Returns:

  • (ZipPackage) —

    the provider of the containing package, e.g. its manifest



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/resync/client/mixins/bitstream_resource.rb', line 8

module Resync
  class Client
    module Mixins
      module BitstreamResource
        attr_accessor :zip_package_delegate

        # @return [ZipPackage] the package containing the bitstream for this resource
        def containing_package
          @zip_package_delegate.zip_package
        end

        # @return [Bitstream] the bitstream for this resource
        def bitstream
          containing_package.bitstream_for(self)
        end
      end
    end
  end
end