Class: ShafClient

Inherits:
Object
  • Object
show all
Extended by:
HypertextCacheStrategy
Includes:
MimeTypes
Defined in:
lib/shaf_client.rb,
lib/shaf_client/form.rb,
lib/shaf_client/link.rb,
lib/shaf_client/curie.rb,
lib/shaf_client/error.rb,
lib/shaf_client/field.rb,
lib/shaf_client/version.rb,
lib/shaf_client/hal_form.rb,
lib/shaf_client/resource.rb,
lib/shaf_client/api_error.rb,
lib/shaf_client/shaf_form.rb,
lib/shaf_client/mime_types.rb,
lib/shaf_client/base_resource.rb,
lib/shaf_client/empty_resource.rb,
lib/shaf_client/resource_mapper.rb,
lib/shaf_client/unknown_resource.rb,
lib/shaf_client/middleware/redirect.rb,
lib/shaf_client/hypertext_cache_strategy.rb

Defined Under Namespace

Modules: HypertextCacheStrategy, Middleware, MimeTypes Classes: AmbiguousRelError, ApiError, BaseResource, Curie, EmptyResource, Error, Field, Form, HalForm, Link, Resource, ResourceMapper, ShafForm, UnSupportedContentType, UnknownResource

Constant Summary collapse

DEFAULT_ADAPTER =
:net_http
VERSION =
"0.7.0"

Constants included from HypertextCacheStrategy

HypertextCacheStrategy::AVAILABLE_CACHE_STRATEGIES

Constants included from MimeTypes

MimeTypes::MIME_TYPE_HAL, MimeTypes::MIME_TYPE_JSON

Instance Method Summary collapse

Methods included from HypertextCacheStrategy

cacheable?, default_headers, default_http_status, default_hypertext_cache_strategy, default_hypertext_cache_strategy=, fetch_headers?

Constructor Details

#initialize(root_uri, **options) ⇒ ShafClient

Returns a new instance of ShafClient.



28
29
30
31
32
33
34
35
# File 'lib/shaf_client.rb', line 28

def initialize(root_uri, **options)
  @root_uri = root_uri.dup
  @options = options

  setup_default_headers
  setup_basic_auth
  setup_client
end

Instance Method Details

#get_root(**options) ⇒ Object



37
38
39
# File 'lib/shaf_client.rb', line 37

def get_root(**options)
  get(@root_uri, **options)
end

#stubsObject



57
58
59
60
# File 'lib/shaf_client.rb', line 57

def stubs
  return unless @adapter == :test
  @stubs ||= Faraday::Adapter::Test::Stubs.new
end