Module: LazyAnt::DSL::Connection

Extended by:
ActiveSupport::Concern
Included in:
LazyAnt::DSL, Endpoint
Defined in:
lib/lazy_ant/dsl/connection.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#connectionObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lazy_ant/dsl/connection.rb', line 9

def connection
  @connection ||= Faraday.new(base_url) do |con|
    con.request :url_encoded
    con.request :json
    con.response converter_name if converter_name
    con.response :json
    con.response :raise_error
    con.adapter Faraday.default_adapter
    instance_exec(con, &default_callback) if default_callback
  end
end

#converter_nameObject



27
28
29
30
31
# File 'lib/lazy_ant/dsl/connection.rb', line 27

def converter_name
  @coverter_name ||=
    self.class.instance_variable_get(:@converter_name) ||
    @parent && @parent.converter_name
end

#default_callbackObject



21
22
23
24
25
# File 'lib/lazy_ant/dsl/connection.rb', line 21

def default_callback
  @default_callback ||=
    self.class.instance_variable_get(:@default_callback) ||
    @parent && @parent.default_callback
end