Sha256: 5dddf6cb4f55bc88f64f71674f4903c0b1f28d0c1bd21174bf9df7c274bb2f26

Contents?: true

Size: 1019 Bytes

Versions: 9

Compression:

Stored size: 1019 Bytes

Contents

require 'saddle/client_attributes'
require 'saddle/method_tree_builder'
require 'saddle/options'
require 'saddle/requester'


# Inherit your client implementation from Saddle::Client
# then call YourCrayClient.create to get a client instance.


module Saddle

  class Client

    extend MethodTreeBuilder
    extend Options

    class << self
      attr_accessor :additional_middlewares
    end

    # Once your implementation is written, this is the magic you need to
    # create a client instance.
    def self.create(opt={})
      self.build_tree(
        Saddle::Requester.new(
          default_options.merge(opt)
        )
      )
    end

    def self.inherited(obj)
      # Clone the parent's additional_middlewares
      obj.additional_middlewares = if defined?(obj.superclass.additional_middlewares)
        (obj.superclass.additional_middlewares || []).clone
      else
        []
      end
      # Add additional client attributes
      obj.send(:include, Saddle::ClientAttributes)
    end    

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
saddle-0.0.23 lib/saddle.rb
saddle-0.0.22 lib/saddle.rb
saddle-0.0.21 lib/saddle.rb
saddle-0.0.19 lib/saddle.rb
saddle-0.0.18 lib/saddle.rb
saddle-0.0.17 lib/saddle.rb
saddle-0.0.16 lib/saddle.rb
saddle-0.0.15 lib/saddle.rb
saddle-0.0.14 lib/saddle.rb