Sha256: 21019143142c33c3ca263cf92f3b0051bdbc2bfe60638f61d0698641855c616d

Contents?: true

Size: 689 Bytes

Versions: 8

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

module Vertebrae
  class API
    include Request

    attr_accessor :connection, :initialisation_options

    # Create new API
    #
    def initialize(options={}, &block)
      self.initialisation_options = options
      options = default_options.merge(options)

      yield_or_eval(&block) if block_given?
      self.connection = Connection.new(options)
      self.connection.configuration.process_basic_auth(options[:basic_auth])
      setup
    end

    def setup
    end

    def default_options
      {}
    end

    def yield_or_eval(&block)
      return unless block
      block.arity > 0 ? yield(self) : self.instance_eval(&block)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vertebrae-0.8.0 lib/vertebrae/api.rb
vertebrae-1.0.5 lib/vertebrae/api.rb
vertebrae-1.0.4 lib/vertebrae/api.rb
vertebrae-1.0.2 lib/vertebrae/api.rb
vertebrae-1.0.1 lib/vertebrae/api.rb
vertebrae-1.0.0 lib/api.rb
vertebrae-0.7.0 lib/api.rb
vertebrae-0.6.2 lib/api.rb