washout_builder 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.rubocop.yml +68 -0
- data/.travis.yml +1 -1
- data/Appraisals +9 -1
- data/Gemfile +2 -3
- data/Rakefile +17 -20
- data/app/controllers/washout_builder/washout_builder_controller.rb +79 -79
- data/app/helpers/washout_builder_complex_type_helper.rb +16 -23
- data/app/helpers/washout_builder_fault_type_helper.rb +12 -13
- data/app/helpers/washout_builder_method_arguments_helper.rb +24 -26
- data/app/helpers/washout_builder_method_list_helper.rb +16 -11
- data/app/helpers/washout_builder_method_return_type_helper.rb +14 -12
- data/app/views/wash_with_html/doc.builder +2 -2
- data/bin/appraisal +16 -0
- data/bin/autospec +16 -0
- data/bin/bundler +16 -0
- data/bin/cdiff +16 -0
- data/bin/coderay +16 -0
- data/bin/colortab +16 -0
- data/bin/coveralls +16 -0
- data/bin/decolor +16 -0
- data/bin/erubis +16 -0
- data/bin/guard +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/listen +16 -0
- data/bin/nokogiri +16 -0
- data/bin/phare +16 -0
- data/bin/pry +16 -0
- data/bin/rackup +16 -0
- data/bin/rails +16 -0
- data/bin/rake +16 -0
- data/bin/restclient +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/ruby-parse +16 -0
- data/bin/ruby-rewrite +16 -0
- data/bin/sass +16 -0
- data/bin/sass-convert +16 -0
- data/bin/scss +16 -0
- data/bin/scss-lint +16 -0
- data/bin/term_display +16 -0
- data/bin/term_mandel +16 -0
- data/bin/thor +16 -0
- data/bin/uuid +16 -0
- data/config/routes.rb +3 -3
- data/init.rb +1 -1
- data/lib/washout_builder.rb +20 -29
- data/lib/washout_builder/document/complex_type.rb +70 -75
- data/lib/washout_builder/document/exception_model.rb +46 -51
- data/lib/washout_builder/document/generator.rb +56 -66
- data/lib/washout_builder/document/shared_complex_type.rb +2 -4
- data/lib/washout_builder/engine.rb +1 -2
- data/lib/washout_builder/soap.rb +6 -10
- data/lib/washout_builder/type.rb +9 -23
- data/lib/washout_builder/version.rb +5 -5
- data/spec/app/controllers/washout_builder_controller_spec.rb +26 -28
- data/spec/app/helpers/washout_builder_complex_type_helper_spec.rb +37 -45
- data/spec/app/helpers/washout_builder_fault_type_helper_spec.rb +65 -77
- data/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb +65 -76
- data/spec/app/helpers/washout_builder_method_list_helper_spec.rb +30 -35
- data/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb +25 -27
- data/spec/dummy/config/application.rb +4 -4
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -3
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/routes.rb +0 -1
- data/spec/dummy/script/rails +2 -2
- data/spec/integration/washout_builder_all_services_spec.rb +2 -5
- data/spec/integration/washout_builder_service_spec.rb +2 -5
- data/spec/lib/washout_builder/document/complex_type_spec.rb +98 -118
- data/spec/lib/washout_builder/document/exception_model_spec.rb +49 -54
- data/spec/lib/washout_builder/document/generator_spec.rb +93 -118
- data/spec/lib/washout_builder/type_spec.rb +17 -29
- data/spec/lib/washout_builder_spec.rb +293 -308
- data/spec/spec_helper.rb +24 -30
- data/spec/support/complex_types/fluffy.rb +3 -3
- data/spec/support/complex_types/fluffy_container.rb +3 -3
- data/spec/support/complex_types/project_type.rb +4 -5
- data/spec/support/complex_types/test_type.rb +4 -4
- data/washout_builder.gemspec +5 -2
- metadata +78 -3
data/bin/rails
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rails' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('railties', 'rails')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/restclient
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'restclient' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rest-client', 'restclient')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/rubocop
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rubocop' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rubocop', 'rubocop')
|
data/bin/ruby-parse
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('parser', 'ruby-parse')
|
data/bin/ruby-rewrite
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('parser', 'ruby-rewrite')
|
data/bin/sass
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'sass' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('sass', 'sass')
|
data/bin/sass-convert
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'sass-convert' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('sass', 'sass-convert')
|
data/bin/scss
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'scss' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('sass', 'scss')
|
data/bin/scss-lint
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'scss-lint' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('scss-lint', 'scss-lint')
|
data/bin/term_display
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'term_display' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('term-ansicolor', 'term_display')
|
data/bin/term_mandel
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'term_mandel' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('term-ansicolor', 'term_mandel')
|
data/bin/thor
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'thor' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('thor', 'thor')
|
data/bin/uuid
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'uuid' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('uuid', 'uuid')
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
WashoutBuilder::Engine.routes.draw do
|
2
|
-
root :
|
3
|
-
match
|
4
|
-
end
|
2
|
+
root to: 'washout_builder#all'
|
3
|
+
match '/*name' => 'washout_builder#all', :as => :washout_builder_service, :via => :get
|
4
|
+
end
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'washout_builder'
|
1
|
+
require 'washout_builder'
|
data/lib/washout_builder.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
require 'wash_out'
|
2
|
-
Gem.find_files(
|
2
|
+
Gem.find_files('washout_builder/**/*.rb').each { |path| require path }
|
3
3
|
|
4
4
|
WashOut::Param.send :include, WashoutBuilder::Document::ComplexType
|
5
5
|
|
6
|
-
|
7
|
-
WashoutBuilder::Type.get_fault_classes.each do |exception_class|
|
6
|
+
WashoutBuilder::Type.all_fault_classes.each do |exception_class|
|
8
7
|
exception_class.class_eval do
|
9
8
|
extend WashoutBuilder::Document::ExceptionModel
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
12
|
if defined?(WashOut::SOAP)
|
15
13
|
WashOut::SOAP::ClassMethods.class_eval do
|
16
14
|
alias_method :original_soap_action, :soap_action
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
18
|
if defined?(WashOut::Rails::Controller)
|
22
19
|
WashOut::Rails::Controller::ClassMethods.class_eval do
|
23
20
|
alias_method :original_soap_action, :soap_action
|
@@ -26,28 +23,25 @@ end
|
|
26
23
|
|
27
24
|
if defined?(WashOut::SoapConfig)
|
28
25
|
WashOut::SoapConfig.class_eval do
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
singleton_class.send(:alias_method, :original_config, :config)
|
27
|
+
singleton_class.send(:alias_method, :original_keys, :keys)
|
28
|
+
|
32
29
|
def self.keys
|
33
30
|
@keys = config.keys
|
34
31
|
end
|
35
|
-
|
32
|
+
|
36
33
|
def self.config
|
37
|
-
original_config.merge(
|
34
|
+
original_config.merge(description: nil)
|
38
35
|
end
|
39
|
-
|
40
36
|
end
|
41
37
|
WashOut::SoapConfig.soap_accessor(:description)
|
42
38
|
end
|
43
39
|
|
44
|
-
|
45
40
|
WashOut::Param.class_eval do
|
46
|
-
|
47
41
|
def self.parse_builder_def(soap_config, definition)
|
48
|
-
raise
|
49
|
-
return [] if definition
|
50
|
-
|
42
|
+
raise '[] should not be used in your params. Use nil if you want to mark empty set.' if definition == []
|
43
|
+
return [] if definition.nil?
|
44
|
+
|
51
45
|
# the following lines was removed because when generating the documentation
|
52
46
|
# the "source_class" attrtibute of the object was not the name of the class of the complex tyoe
|
53
47
|
# but instead was the name given in the hash
|
@@ -58,32 +52,29 @@ WashOut::Param.class_eval do
|
|
58
52
|
# :description => :string,
|
59
53
|
# :users => [{:mail => :string }],
|
60
54
|
# }
|
61
|
-
#end
|
62
|
-
#
|
55
|
+
# end
|
56
|
+
#
|
63
57
|
# The name of the complex type should be ProjectType and not "project"
|
64
|
-
|
65
|
-
|
58
|
+
|
66
59
|
# if definition.is_a?(Class) && definition.ancestors.include?(WashOut::Type)
|
67
60
|
# definition = definition.wash_out_param_map
|
68
61
|
# end
|
69
|
-
|
70
|
-
definition = { :
|
71
|
-
|
72
|
-
definition.
|
62
|
+
|
63
|
+
definition = { value: definition } unless definition.is_a?(Hash) # for arrays and symbols
|
64
|
+
|
65
|
+
definition.map do |name, opt|
|
73
66
|
if opt.is_a? WashOut::Param
|
74
67
|
opt
|
75
68
|
elsif opt.is_a? Array
|
76
69
|
WashOut::Param.new(soap_config, name, opt[0], true)
|
77
70
|
else
|
78
71
|
WashOut::Param.new(soap_config, name, opt)
|
79
|
-
end
|
80
72
|
end
|
81
73
|
end
|
82
|
-
|
74
|
+
end
|
83
75
|
end
|
84
|
-
|
85
|
-
ActionController::Base.class_eval do
|
86
76
|
|
77
|
+
ActionController::Base.class_eval do
|
87
78
|
# Define a SOAP service. The function has no required +options+:
|
88
79
|
# but allow any of :parser, :namespace, :wsdl_style, :snakecase_input,
|
89
80
|
# :camelize_wsdl, :wsse_username, :wsse_password and :catch_xml_errors.
|
@@ -91,7 +82,7 @@ ActionController::Base.class_eval do
|
|
91
82
|
# Any of the the params provided allows for overriding the defaults
|
92
83
|
# (like supporting multiple namespaces instead of application wide such)
|
93
84
|
#
|
94
|
-
def self.soap_service(options={})
|
85
|
+
def self.soap_service(options = {})
|
95
86
|
include WashoutBuilder::SOAP
|
96
87
|
self.soap_config = options
|
97
88
|
end
|
@@ -1,124 +1,119 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative './shared_complex_type'
|
2
2
|
module WashoutBuilder
|
3
3
|
module Document
|
4
4
|
module ComplexType
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
include WashoutBuilder::Document::SharedComplexType
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
complex_class
|
11
|
-
|
12
|
-
unless complex_class.nil? || defined.blank?
|
13
|
-
|
14
|
-
complex_obj_found = defined.detect {|hash| hash[:class] == complex_class}
|
15
|
-
|
16
|
-
if !complex_obj_found.nil? && struct? && !classified?
|
17
|
-
raise RuntimeError, "Duplicate use of `#{basic_type}` type name. Consider using classified types."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
7
|
+
|
8
|
+
def find_complex_class_name(defined = [])
|
9
|
+
complex_class = struct? ? basic_type.gsub('.', '/').camelize : nil
|
10
|
+
check_duplicate_complex_class(defined, complex_class) unless complex_class.nil? || defined.blank?
|
21
11
|
complex_class
|
22
12
|
end
|
23
|
-
|
24
|
-
|
13
|
+
|
14
|
+
def check_duplicate_complex_class(defined, complex_class)
|
15
|
+
complex_obj_found = defined.find { |hash| hash[:class] == complex_class }
|
16
|
+
raise "Duplicate use of `#{basic_type}` type name. Consider using classified types." if !complex_obj_found.nil? && struct? && !classified?
|
17
|
+
end
|
18
|
+
|
25
19
|
def complex_type_ancestors(config, complex_class, defined)
|
26
|
-
classified?
|
20
|
+
classified? ? get_class_ancestors(config, complex_class, defined) : nil
|
27
21
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
|
23
|
+
def find_param_structure
|
24
|
+
map.each_with_object({}) do|item, memo|
|
25
|
+
memo[item.name] = item.type
|
26
|
+
memo
|
27
|
+
end
|
32
28
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
self.map = self.map.delete_if{|element| keys.include?(element.name) }
|
29
|
+
|
30
|
+
def remove_type_inheritable_elements(keys)
|
31
|
+
self.map = map.delete_if { |element| keys.include?(element.name) }
|
37
32
|
end
|
38
|
-
|
33
|
+
|
39
34
|
# def get_ancestor_structure
|
40
35
|
# {self.class.to_s.downcase => self.class.columns_hash.inject({}) {|h, (k,v)| h["#{k}"]="#{v.type}".to_sym; h } }
|
41
36
|
# end
|
42
|
-
|
43
|
-
|
37
|
+
|
44
38
|
def fix_descendant_wash_out_type(config, complex_class)
|
45
|
-
param_class =
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
self.map = descendant.map
|
39
|
+
param_class = begin
|
40
|
+
complex_class.is_a?(Class) ? complex_class : complex_class.constantize
|
41
|
+
rescue
|
42
|
+
nil
|
50
43
|
end
|
44
|
+
return unless param_class.present? && param_class.ancestors.include?(WashOut::Type) && map[0].present?
|
45
|
+
descendant = WashOut::Param.parse_builder_def(config, param_class.wash_out_param_map)[0]
|
46
|
+
self.name = descendant.name
|
47
|
+
self.map = descendant.map
|
51
48
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if param_structure.keys == ancestor_structure.keys
|
49
|
+
|
50
|
+
def same_structure_as_ancestor?(ancestor)
|
51
|
+
param_structure = find_param_structure
|
52
|
+
ancestor_structure = ancestor.find_param_structure
|
53
|
+
if param_structure.keys == ancestor_structure.keys
|
58
54
|
return true
|
59
|
-
else
|
60
|
-
remove_type_inheritable_elements(
|
55
|
+
else
|
56
|
+
remove_type_inheritable_elements(ancestor_structure.keys)
|
61
57
|
return false
|
62
58
|
end
|
63
59
|
end
|
64
|
-
|
65
|
-
|
60
|
+
|
66
61
|
def get_ancestors(class_name)
|
67
|
-
param_class =
|
68
|
-
|
62
|
+
param_class = begin
|
63
|
+
class_name.is_a?(Class) ? class_name : class_name.constantize
|
64
|
+
rescue
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
if param_class.nil?
|
69
68
|
return nil
|
70
69
|
else
|
71
|
-
get_complex_type_ancestors(param_class, [
|
70
|
+
get_complex_type_ancestors(param_class, ['ActiveRecord::Base', 'Object', 'BasicObject', 'WashOut::Type'])
|
72
71
|
end
|
73
72
|
end
|
74
|
-
|
75
|
-
|
76
|
-
def complex_type_descendants(config,defined)
|
73
|
+
|
74
|
+
def complex_type_descendants(config, defined)
|
77
75
|
if struct?
|
78
76
|
c_names = []
|
79
|
-
map.each { |obj|
|
77
|
+
map.each { |obj| c_names.concat(obj.get_nested_complex_types(config, defined)) }
|
80
78
|
defined.concat(c_names)
|
81
79
|
end
|
82
80
|
defined
|
83
81
|
end
|
84
|
-
|
85
|
-
|
86
|
-
def get_nested_complex_types(config,defined)
|
82
|
+
|
83
|
+
def get_nested_complex_types(config, defined)
|
87
84
|
defined = [] if defined.blank?
|
88
|
-
complex_class =
|
89
|
-
fix_descendant_wash_out_type(
|
85
|
+
complex_class = find_complex_class_name(defined)
|
86
|
+
fix_descendant_wash_out_type(config, complex_class)
|
90
87
|
unless complex_class.nil?
|
91
88
|
defined << complex_type_hash(complex_class, self, complex_type_ancestors(config, complex_class, defined))
|
92
89
|
end
|
93
90
|
defined = complex_type_descendants(config, defined)
|
94
91
|
defined.sort_by { |hash| hash[:class].to_s.downcase }.uniq unless defined.blank?
|
95
92
|
end
|
96
|
-
|
97
|
-
|
93
|
+
|
98
94
|
def ancestor_structure(ancestors)
|
99
95
|
{ ancestors[0].to_s.downcase => ancestors[0].wash_out_param_map }
|
100
96
|
end
|
101
|
-
|
97
|
+
|
102
98
|
def complex_type_hash(class_name, object, ancestors)
|
103
|
-
{
|
99
|
+
{
|
100
|
+
'class' => class_name,
|
101
|
+
obj: object,
|
102
|
+
ancestors: ancestors
|
103
|
+
}
|
104
104
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
top_ancestors = get_class_ancestors(config, ancestors[0], defined)
|
115
|
-
defined << complex_type_hash(ancestors[0],ancestor_object , top_ancestors)
|
116
|
-
end
|
117
|
-
ancestors unless bool_the_same
|
105
|
+
|
106
|
+
def get_class_ancestors(config, class_name, defined)
|
107
|
+
ancestors = get_ancestors(class_name)
|
108
|
+
return if ancestors.blank?
|
109
|
+
ancestor_object = WashOut::Param.parse_def(config, ancestor_structure(ancestors))[0]
|
110
|
+
bool_the_same = same_structure_as_ancestor?(ancestor_object)
|
111
|
+
unless bool_the_same
|
112
|
+
top_ancestors = get_class_ancestors(config, ancestors[0], defined)
|
113
|
+
defined << complex_type_hash(ancestors[0], ancestor_object, top_ancestors)
|
118
114
|
end
|
115
|
+
ancestors unless bool_the_same
|
119
116
|
end
|
120
|
-
|
121
|
-
|
122
117
|
end
|
123
118
|
end
|
124
119
|
end
|