Module: Rooftop::Client

Defined in:
lib/rooftop/client.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rooftop/client.rb', line 3

def self.included(base)
  if Rooftop.configuration.url.nil?
    raise ArgumentError, "You need to configure Rooftop before instantiating a class with a Rooftop mixin"
  end

  Her::API.setup url: Rooftop.configuration.url do |c|
    #Headers
    c.use Rooftop::Headers

    # Request
    c.use Faraday::Request::UrlEncoded

    # Response
    c.use Her::Middleware::DefaultParseJSON

    # Adapter
    c.use Faraday::Adapter::NetHttp
  end
  base.include Her::Model
end