Sha256: 49e060626b12c3e2e7f61297c390aaea3e49d7bbb5c7bcb86a4a4b96415ede3f

Contents?: true

Size: 461 Bytes

Versions: 29

Compression:

Stored size: 461 Bytes

Contents

module ActiveRestClient
  class LazyLoader
    def initialize(request, params = nil)
      @request = request
      @params = params
      @result = nil
    end

    def method_missing(name, *args)
      if @result.nil?
        @result = @request.call(@params)
      end
      @result.send(name, *args)
    end

    def respond_to?(name)
      if @result.nil?
        @result = @request.call(@params)
      end
      @result.respond_to?(name)
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
active_rest_client-1.2.0 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.1.12 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.1.11 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.1.10 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.1.9 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.1.0 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.9 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.8 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.7 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.6 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.5 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.4 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.3 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.2 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.1 lib/active_rest_client/lazy_loader.rb
active_rest_client-1.0.0 lib/active_rest_client/lazy_loader.rb
active_rest_client-0.9.75 lib/active_rest_client/lazy_loader.rb
active_rest_client-0.9.73 lib/active_rest_client/lazy_loader.rb
active_rest_client-0.9.72 lib/active_rest_client/lazy_loader.rb
active_rest_client-0.9.71 lib/active_rest_client/lazy_loader.rb