smooth_operator 1.8.3 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2JjYWE0YjEwY2U0MTk1NWIwZTYxMzlkZTQxNjcwM2M3NDNlZGI4Zg==
4
+ ZjAzMDZjMmQ3N2JkNzEzOWQ0MWNlNzcyNjc1ZjdkNzg1ZjI4MzdiMQ==
5
5
  data.tar.gz: !binary |-
6
- ZGQxNjU4NDk4OGFhZmM5NjdmYzAwNWVjOTE3YmQzMDdjZjVhMTc4YQ==
6
+ NTBiYjI0ODhhNzM1MzE4Y2FkOWJkOGRhMDBhYTIzNDU4NDAzNzVhNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjVhMWJmNzE3YTM2YzI0OTQ1YjIyNTBjYTFiODk2Y2NmZmM1YzIzY2E3M2E0
10
- NzI1OGM4YWRhOTQyNzVkNmRjMzAwMDM3MzI0MjJlOGFlODYwODNkMjg2Y2Nm
11
- OWNiNjE3NzZlYjc0OGRmY2Y4NTVhNGFlODI2N2JjYmNkNGRkZDI=
9
+ ZGViNTdmZDI2N2E5MWQ1NmYwOGQ1ZDI3MjAxNjg1ODBiYTIxZjhhYjJjNjBh
10
+ MTNiMjFjOGI5M2ZhNTNkOTI4NDEyMzcyNGUyOTNhNjdiZmYwNjliZWEyZDQ5
11
+ ZGNkODYzYzA2MzY0N2QwOGViMmY0ODFhZWI5MjRhMWZmMmM0MmE=
12
12
  data.tar.gz: !binary |-
13
- NjM1ZDQ5NTI5YzI3MmE2Mjk2ZDQ3NmY0OGQ2OGU3ZjkzMWE5ZTVmZDNiMzQ3
14
- ZjA5YWIyYWNhZWZhNTY4NDhiOTc4MWUzY2ZlYWYyMDQzM2M0MWU4ZjE0M2Vl
15
- OWVhOTMzYzAzNTI4YmQzNTkzMDEwYjA5MGU1MTY3ODM5NTI1ZmM=
13
+ MzkzMzUyZmQ1MDUxNzI4NjVlOGFkMWNhZjVlNTljZTQ5M2ZkZjA5YWMyOTQx
14
+ NjdjZTgxNmQ1MDI0NDQ5ZTE1NzMwZTBjNzMzYTgyNTMzNDIzMDM5Y2Y1OTc4
15
+ NGMwZDNkNmRhZmMxOWJiNGU4YmJmMzQyMDc1MjM4NTBlNzFiMjA=
@@ -20,6 +20,8 @@ module SmoothOperator
20
20
  protected #################### PROTECTED ##################
21
21
 
22
22
  def build_object(parsed_response, options)
23
+ options ||={}
24
+
23
25
  table_name = (options[:table_name] || self.table_name).to_s
24
26
 
25
27
  if parsed_response.is_a?(Array)
@@ -49,23 +49,23 @@ module SmoothOperator
49
49
  if defined? ActiveModel
50
50
  rails_model_name_method
51
51
  else
52
- @_model_name_namespace ||= name.split('::').last.underscore.capitalize
52
+ @_model_name ||= name.split('::').last.underscore.capitalize
53
53
  end
54
54
  end
55
55
 
56
56
  def model_name=(name)
57
- @_model_name_namespace = name
57
+ @_model_name = name
58
58
  end
59
59
 
60
60
 
61
61
  protected ############## PROTECTED #############
62
62
 
63
63
  def rails_model_name_method
64
- @_model_name ||= begin
65
- @_model_name_namespace ||= self.parents.detect do |n|
64
+ @model_name ||= begin
65
+ namespace ||= self.parents.detect do |n|
66
66
  n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
67
67
  end
68
- ActiveModel::Name.new(self, @_model_name_namespace)
68
+ ActiveModel::Name.new(self, namespace, @_model_name)
69
69
  end
70
70
  end
71
71
 
@@ -19,6 +19,12 @@ module SmoothOperator
19
19
  HTTP_VERBS.each { |http_verb| define_method(http_verb) { |relative_path = '', params = {}, options = {}| make_the_call(http_verb, relative_path, params, options) } }
20
20
 
21
21
 
22
+ def headers
23
+ Helpers.get_instance_variable(self, :headers, {})
24
+ end
25
+ attr_writer :headers
26
+
27
+
22
28
  def generate_parallel_connection
23
29
  generate_connection(:typhoeus)
24
30
  end
@@ -51,8 +57,9 @@ module SmoothOperator
51
57
 
52
58
  response = connection.send(http_verb) do |request|
53
59
  operator_options.each { |key, value| request.options.send("#{key}=", value) }
60
+ options[:headers].each { |key, value| request.headers[key] = value }
54
61
  params.each { |key, value| request.params[key] = value }
55
-
62
+
56
63
  request.url relative_path
57
64
  request.body = body
58
65
  end
@@ -90,6 +97,7 @@ module SmoothOperator
90
97
  def strip_options(options)
91
98
  options ||= {}
92
99
 
100
+ options[:headers] = self.headers.merge(options[:headers] || {})
93
101
  operator_options = options.delete(:operator_options) || {}
94
102
  connection = options.delete(:connection) || generate_connection(nil, operator_options)
95
103
 
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = "1.8.3"
2
+ VERSION = "1.8.5"
3
3
  end
@@ -1,3 +1,10 @@
1
1
  class Address < SmoothOperator::Base
2
+ self.model_name = 'user'
2
3
 
4
+ self.endpoint_user = 'admin'
5
+ self.endpoint_pass = 'admin'
6
+
7
+ self.endpoint = 'http://localhost:4567/'
8
+
9
+ self.headers = { "X-APPTOKEN" => "joaquim_app_token", "X-LAYERTOKEN" => "joaquim_layer_token" }
3
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves