Module: Resync::Client::Mixins::ClientDelegator

Included in:
Downloadable, LinkClientDelegate, ResourceClientDelegate
Defined in:
lib/resync/client/mixins/client_delegator.rb

Overview

An object that delegates to another to provide a Resync::Client for downloading resources and links.

Defined Under Namespace

Classes: ClientDelegate

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_delegate#client

Returns The client provider.

Returns:

  • (#client)

    The client provider.



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
# File 'lib/resync/client/mixins/client_delegator.rb', line 11

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

Instance Method Details

#clientObject



14
15
16
# File 'lib/resync/client/mixins/client_delegator.rb', line 14

def client
  client_delegate.client
end

#client=(value) ⇒ Object

Creates a one-off delegate wrapper around the specified Resync::Client

Parameters:

  • value (Client)

    the client



20
21
22
# File 'lib/resync/client/mixins/client_delegator.rb', line 20

def client=(value)
  @client_delegate = ClientDelegate.new(value)
end