washout_builder 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce93207677248ea25aec7558a3266667c7e1ee45
4
- data.tar.gz: 71325291f14d1069c7754c4ba5add1f367cd3335
3
+ metadata.gz: 90cecf99023dfa0b735e1089ba1cb4eb5b077b26
4
+ data.tar.gz: 900363bc936101a18329bd7f3763c379307b76d3
5
5
  SHA512:
6
- metadata.gz: f6ab9c9c591e68539ffd4f7052f723765a42adfc5401d53866578122771f36b61bfcb9ffb162f5e2b31a00cf15cf564f6cdee853b823f3cef80add358ba109c6
7
- data.tar.gz: 70785954e5697320a6c42948f302205120df5632482be8420e38fe8a6b644c093321c0e89402fee3221920857e25d150ab7cd02500cd54b0204e76da8d294cd7
6
+ metadata.gz: 3bd47a0cea30d670da9337b8f9dc500363503845350e3fbee7063506511c63a9ea138588ba71d360293a174cbde1bcaba7a878a27f32e79983468def29865271
7
+ data.tar.gz: f7de742d4af8d318ab18029986788eb8610340aa1f987243940ca85d0af7f81860283005401bdc645dfb4bb4710a6ffd27123ae1c09b5c8df064ec2e6377262e
@@ -81,17 +81,27 @@ module WashoutBuilder
81
81
  # @return [void]
82
82
  # @api public
83
83
  def fix_descendant_wash_out_type(config, complex_class)
84
- param_class = begin
85
- complex_class.is_a?(Class) ? complex_class : complex_class.constantize
86
- rescue
87
- nil
88
- end
89
- return unless param_class.present? && param_class.ancestors.include?(WashOut::Type) && map[0].present?
90
- descendant = WashOut::Param.parse_builder_def(config, param_class.wash_out_param_map)[0]
84
+ param_class = find_class_from_string(complex_class)
85
+ base_param_class = WashoutBuilder::Type.base_param_class
86
+ base_type_class = WashoutBuilder::Type.base_type_class
87
+ return if base_param_class.blank? || base_type_class.blank?
88
+ return unless param_class.present? && param_class.ancestors.include?(base_type_class) && map[0].present?
89
+ descendant = base_param_class.parse_builder_def(config, param_class.wash_out_param_map)[0]
91
90
  self.name = descendant.name
92
91
  self.map = descendant.map
93
92
  end
94
93
 
94
+ # Description of method
95
+ #
96
+ # @param [String] complex_class A string that contains the name of a class
97
+ # @return [Class, nil] returns the class if it is defined otherwise nil
98
+ # @api public
99
+ def find_class_from_string(complex_class)
100
+ complex_class.is_a?(Class) ? complex_class : complex_class.constantize
101
+ rescue
102
+ nil
103
+ end
104
+
95
105
  # Method that is used to check if the current object has exactly same structure as one of his ancestors
96
106
  # if it is true, will return true, otherwise will first remove the inheritated elements from his ancestor and then return false
97
107
  # @see #find_param_structure
@@ -120,15 +130,14 @@ module WashoutBuilder
120
130
  # 'ActiveRecord::Base', 'Object', 'BasicObject', 'WashOut::Type'
121
131
  # @api public
122
132
  def get_ancestors(class_name)
123
- param_class = begin
124
- class_name.is_a?(Class) ? class_name : class_name.constantize
125
- rescue
126
- nil
127
- end
133
+ param_class = find_class_from_string(class_name)
128
134
  if param_class.nil?
129
135
  return nil
130
136
  else
131
- get_complex_type_ancestors(param_class, ['ActiveRecord::Base', 'Object', 'BasicObject', 'WashOut::Type'])
137
+ base_type_class = WashoutBuilder::Type.base_type_class
138
+ filtered_classes = ['ActiveRecord::Base', 'Object', 'BasicObject']
139
+ filtered_classes << base_type_class.to_s if base_type_class.present?
140
+ get_complex_type_ancestors(param_class, filtered_classes)
132
141
  end
133
142
  end
134
143
 
@@ -210,7 +219,9 @@ module WashoutBuilder
210
219
  def get_class_ancestors(config, class_name, defined)
211
220
  ancestors = get_ancestors(class_name)
212
221
  return if ancestors.blank?
213
- ancestor_object = WashOut::Param.parse_def(config, ancestor_structure(ancestors))[0]
222
+ base_param_class = WashoutBuilder::Type.base_param_class
223
+ return if base_param_class.blank?
224
+ ancestor_object = base_param_class.parse_def(config, ancestor_structure(ancestors))[0]
214
225
  bool_the_same = same_structure_as_ancestor?(ancestor_object)
215
226
  unless bool_the_same
216
227
  top_ancestors = get_class_ancestors(config, ancestors[0], defined)
@@ -30,8 +30,10 @@ module WashoutBuilder
30
30
  end
31
31
 
32
32
  current_action = soap_actions[action]
33
- current_action[:builder_in] = WashOut::Param.parse_builder_def(soap_config, options[:args])
34
- current_action[:builder_out] = WashOut::Param.parse_builder_def(soap_config, options[:return])
33
+ base_param_class = WashoutBuilder::Type.base_param_class
34
+ return if base_param_class.blank?
35
+ current_action[:builder_in] = base_param_class.parse_builder_def(soap_config, options[:args])
36
+ current_action[:builder_out] = base_param_class.parse_builder_def(soap_config, options[:return])
35
37
  end
36
38
  end
37
39
  end
@@ -35,6 +35,13 @@ module WashoutBuilder
35
35
  defined?(WashOut::Param) ? WashOut::Param : nil
36
36
  end
37
37
 
38
+ # returns the base class that is used for WashOut types
39
+ #
40
+ # @return [Class] returns the base class that is used for WashOut types
41
+ # @api public
42
+ def self.base_type_class
43
+ defined?(WashOut::Type) ? WashOut::Type : nil
44
+ end
38
45
  # returns all the soap config classss that should be overriden to allow description of web service also besides namespace and endpoint
39
46
  #
40
47
  # @return [Array<Class>] returns all the soap config classss that should be overriden to allow description of web service also besides namespace and endpoint
@@ -12,7 +12,7 @@ module WashoutBuilder
12
12
  # the minor version of the gem
13
13
  MINOR = 0
14
14
  # the tiny version of the gem
15
- TINY = 2
15
+ TINY = 4
16
16
  # if the version should be a e
17
17
  PRE = nil
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada