Module: Her::WebMock::Helper

Defined in:
lib/her/webmock/model.rb

Class Method Summary collapse

Class Method Details

.attributes_without_embedded_associations(klass, object) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/her/webmock/model.rb', line 8

def self.attributes_without_embedded_associations(klass, object)
  attributes = object.respond_to?(:attributes) ? object.attributes.dup : object.dup

  klass.associations.each do |type, |
    .each do ||
      association = attributes.delete([:name])

      attributes[[:foreign_key]] = association.id if association
    end
  end

  attributes
end

.default_headersObject



33
34
35
# File 'lib/her/webmock/model.rb', line 33

def self.default_headers
  WebMock.config.default_request_test_headers
end

.request_params(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/her/webmock/model.rb', line 22

def self.request_params(options = {})
  request_params = {}

  request_params[:query] = options[:query]

  headers_hash = default_headers.merge(options.fetch(:headers, {}))
  request_params[:headers] = headers_hash unless headers_hash.empty?

  request_params
end