puppet 5.5.21 → 5.5.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +13 -14
  4. data/lib/puppet/configurer.rb +20 -3
  5. data/lib/puppet/configurer/downloader.rb +31 -10
  6. data/lib/puppet/defaults.rb +7 -1
  7. data/lib/puppet/file_serving/mount/locales.rb +1 -2
  8. data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
  9. data/lib/puppet/file_serving/mount/plugins.rb +1 -2
  10. data/lib/puppet/functions/new.rb +8 -3
  11. data/lib/puppet/functions/reverse_each.rb +1 -1
  12. data/lib/puppet/functions/step.rb +1 -1
  13. data/lib/puppet/indirector/hiera.rb +4 -0
  14. data/lib/puppet/node/environment.rb +7 -1
  15. data/lib/puppet/parser/functions.rb +13 -9
  16. data/lib/puppet/pops/adaptable.rb +7 -13
  17. data/lib/puppet/pops/adapters.rb +8 -4
  18. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  19. data/lib/puppet/pops/types/iterable.rb +34 -8
  20. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  21. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  22. data/lib/puppet/pops/validation/checker4_0.rb +19 -15
  23. data/lib/puppet/provider/package/gem.rb +4 -2
  24. data/lib/puppet/provider/package/puppet_gem.rb +5 -0
  25. data/lib/puppet/provider/package/yum.rb +1 -0
  26. data/lib/puppet/resource/type.rb +2 -1
  27. data/lib/puppet/test/test_helper.rb +5 -2
  28. data/lib/puppet/util.rb +13 -12
  29. data/lib/puppet/util/autoload.rb +9 -7
  30. data/lib/puppet/version.rb +1 -1
  31. data/locales/puppet.pot +33 -29
  32. data/man/man5/puppet.conf.5 +10 -2
  33. data/man/man8/puppet-agent.8 +1 -1
  34. data/man/man8/puppet-apply.8 +1 -1
  35. data/man/man8/puppet-ca.8 +1 -1
  36. data/man/man8/puppet-catalog.8 +1 -1
  37. data/man/man8/puppet-cert.8 +1 -1
  38. data/man/man8/puppet-certificate.8 +1 -1
  39. data/man/man8/puppet-certificate_request.8 +1 -1
  40. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  41. data/man/man8/puppet-config.8 +1 -1
  42. data/man/man8/puppet-describe.8 +1 -1
  43. data/man/man8/puppet-device.8 +1 -1
  44. data/man/man8/puppet-doc.8 +1 -1
  45. data/man/man8/puppet-epp.8 +1 -1
  46. data/man/man8/puppet-facts.8 +1 -1
  47. data/man/man8/puppet-filebucket.8 +1 -1
  48. data/man/man8/puppet-generate.8 +1 -1
  49. data/man/man8/puppet-help.8 +1 -1
  50. data/man/man8/puppet-key.8 +1 -1
  51. data/man/man8/puppet-lookup.8 +1 -1
  52. data/man/man8/puppet-man.8 +1 -1
  53. data/man/man8/puppet-master.8 +1 -1
  54. data/man/man8/puppet-module.8 +1 -1
  55. data/man/man8/puppet-node.8 +1 -1
  56. data/man/man8/puppet-parser.8 +1 -1
  57. data/man/man8/puppet-plugin.8 +1 -1
  58. data/man/man8/puppet-report.8 +1 -1
  59. data/man/man8/puppet-resource.8 +1 -1
  60. data/man/man8/puppet-script.8 +1 -1
  61. data/man/man8/puppet-status.8 +1 -1
  62. data/man/man8/puppet.8 +2 -2
  63. data/spec/integration/configurer_spec.rb +14 -0
  64. data/spec/integration/data_binding_spec.rb +1 -0
  65. data/spec/integration/faces/plugin_spec.rb +29 -47
  66. data/spec/shared_contexts/types_setup.rb +2 -0
  67. data/spec/unit/configurer/downloader_spec.rb +10 -0
  68. data/spec/unit/configurer_spec.rb +65 -30
  69. data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
  70. data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
  71. data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
  72. data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
  73. data/spec/unit/provider/package/yum_spec.rb +31 -0
  74. data/spec/unit/ssl/host_spec.rb +2 -0
  75. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e0d66f006996d2e1696186adfd42a41b3e13eaa6bf9ef2c6807b8b63a75017
4
- data.tar.gz: 150d06e79adfca72573842ddc751a8db13e0fa00e38bc5d96d77cefd6e4d9528
3
+ metadata.gz: 14f6097fec24c016827b29ec50cdfb647316d37c9dfa5fde1a84fd860ea1d936
4
+ data.tar.gz: 05dd855255a0ae58339df332390420cb92fd79bbbc1de398739f3e256115fbdd
5
5
  SHA512:
6
- metadata.gz: 5243ce174453e7e7cdf01e5c080c2eaeee9dc8bc7af0f5054669837e62f68f05368c477919d428660d5fce7759db34f72463f7d5c33ecbfbdfd20d5b5bd10973
7
- data.tar.gz: 550da82fb9ff3ced0d64651f1484678d17d338920dbf72a314e3890da95e12193eaa2ab6ae2428504b9e649999845929953cf3511d83052e26e92b9bff6ab580
6
+ metadata.gz: 5007a3f5f4fa9c2fb875f4343b9fbe3e11c2f5a5986c5f092e5aaf6345336ee1043733ec38fa67097d43ed89bcb8bace41105a66ce71b851b914deac1fedf0e3
7
+ data.tar.gz: 1207c236cf47ad666384405b5d5810f46ed03357f5caa6125c73f9a72ca15929f2bbe053e8df960458c0b82d862b862986b3d7c20f24fcd8fe30b1ec03545826
data/Gemfile CHANGED
@@ -72,8 +72,8 @@ group(:development, :test) do
72
72
  gem 'addressable', '< 2.5.0'
73
73
  # webmock requires hashdiff which requires ruby 2 as of 0.3.9
74
74
  gem 'hashdiff', '0.3.8'
75
- gem 'webmock', '~> 1.24'
76
- gem 'vcr', '~> 2.9'
75
+ gem 'webmock', '~> 2.3'
76
+ gem 'vcr', '~> 5.0'
77
77
  gem "hiera-eyaml", *location_for(ENV['HIERA_EYAML_LOCATION'])
78
78
 
79
79
  gem 'memory_profiler', :platforms => [:mri_21, :mri_22, :mri_23, :mri_24, :mri_25]
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (5.5.21)
4
+ puppet (5.5.22)
5
5
  CFPropertyList (~> 2.2)
6
6
  facter (>= 2.4.0, < 4)
7
7
  fast_gettext (~> 1.1.2)
@@ -20,8 +20,7 @@ GEM
20
20
  ast (2.4.1)
21
21
  builder (3.2.4)
22
22
  coderay (1.1.3)
23
- crack (0.4.3)
24
- safe_yaml (~> 1.0.0)
23
+ crack (0.4.4)
25
24
  csv (3.1.5)
26
25
  diff-lcs (1.4.4)
27
26
  docopt (0.6.1)
@@ -49,16 +48,17 @@ GEM
49
48
  method_source (1.0.0)
50
49
  mocha (1.11.2)
51
50
  msgpack (1.3.3)
52
- multi_json (1.14.1)
51
+ multi_json (1.15.0)
53
52
  mustache (1.1.1)
54
53
  net-ssh (4.2.0)
55
54
  optimist (3.0.1)
56
- packaging (0.99.66)
55
+ packaging (0.99.71)
57
56
  artifactory (~> 2)
57
+ csv (= 3.1.5)
58
58
  rake (>= 12.3)
59
59
  release-metrics
60
60
  parallel (1.19.2)
61
- parser (2.7.1.4)
61
+ parser (2.7.2.0)
62
62
  ast (~> 2.4.1)
63
63
  pathspec (0.2.1)
64
64
  powerpack (0.1.2)
@@ -79,7 +79,7 @@ GEM
79
79
  rack (1.6.13)
80
80
  rainbow (2.1.0)
81
81
  rake (12.3.3)
82
- rdiscount (2.2.0.1)
82
+ rdiscount (2.2.0.2)
83
83
  rdoc (4.3.0)
84
84
  redcarpet (2.3.0)
85
85
  release-metrics (1.1.0)
@@ -95,7 +95,7 @@ GEM
95
95
  rspec-mocks (~> 3.9.0)
96
96
  rspec-collection_matchers (1.2.0)
97
97
  rspec-expectations (>= 2.99.0.beta1)
98
- rspec-core (3.9.2)
98
+ rspec-core (3.9.3)
99
99
  rspec-support (~> 3.9.3)
100
100
  rspec-expectations (3.9.2)
101
101
  diff-lcs (>= 1.2.0, < 2.0)
@@ -108,7 +108,7 @@ GEM
108
108
  rspec-mocks (3.9.1)
109
109
  diff-lcs (>= 1.2.0, < 2.0)
110
110
  rspec-support (~> 3.9.0)
111
- rspec-puppet (2.7.8)
111
+ rspec-puppet (2.7.10)
112
112
  rspec
113
113
  rspec-support (3.9.3)
114
114
  rubocop (0.49.1)
@@ -122,11 +122,10 @@ GEM
122
122
  rubocop (~> 0.49.0)
123
123
  ruby-prof (1.4.1)
124
124
  ruby-progressbar (1.10.1)
125
- safe_yaml (1.0.5)
126
125
  text (1.3.1)
127
126
  unicode-display_width (1.7.0)
128
- vcr (2.9.3)
129
- webmock (1.24.6)
127
+ vcr (5.1.0)
128
+ webmock (2.3.2)
130
129
  addressable (>= 2.3.6)
131
130
  crack (>= 0.3.2)
132
131
  hashdiff
@@ -164,8 +163,8 @@ DEPENDENCIES
164
163
  rubocop (~> 0.49.1)
165
164
  rubocop-i18n (~> 1.2.0)
166
165
  ruby-prof (>= 0.16.0)
167
- vcr (~> 2.9)
168
- webmock (~> 1.24)
166
+ vcr (~> 5.0)
167
+ webmock (~> 2.3)
169
168
  yard
170
169
  yarjuf (~> 2.0)
171
170
 
@@ -58,6 +58,7 @@ class Puppet::Configurer
58
58
  def initialize(transaction_uuid = nil, job_id = nil)
59
59
  @running = false
60
60
  @splayed = false
61
+ @pluginsync_failed = false
61
62
  @cached_catalog_status = 'not_used'
62
63
  @environment = Puppet[:environment]
63
64
  @transaction_uuid = transaction_uuid || SecureRandom.uuid
@@ -70,8 +71,16 @@ class Puppet::Configurer
70
71
  # Get the remote catalog, yo. Returns nil if no catalog can be found.
71
72
  def retrieve_catalog(query_options)
72
73
  query_options ||= {}
73
- if (Puppet[:use_cached_catalog] && result = retrieve_catalog_from_cache(query_options))
74
- @cached_catalog_status = 'explicitly_requested'
74
+ if Puppet[:use_cached_catalog] || @pluginsync_failed
75
+ result = retrieve_catalog_from_cache(query_options)
76
+ end
77
+
78
+ if result
79
+ if Puppet[:use_cached_catalog]
80
+ @cached_catalog_status = 'explicitly_requested'
81
+ elsif @pluginsync_failed
82
+ @cached_catalog_status = 'on_failure'
83
+ end
75
84
 
76
85
  Puppet.info _("Using cached catalog from environment '%{environment}'") % { environment: result.environment }
77
86
  else
@@ -528,6 +537,14 @@ class Puppet::Configurer
528
537
  end
529
538
 
530
539
  def download_plugins(remote_environment_for_plugins)
531
- @handler.download_plugins(remote_environment_for_plugins)
540
+ begin
541
+ @handler.download_plugins(remote_environment_for_plugins)
542
+ rescue Puppet::Error => detail
543
+ if !Puppet[:ignore_plugin_errors] && Puppet[:usecacheonfailure]
544
+ @pluginsync_failed = true
545
+ else
546
+ raise detail
547
+ end
548
+ end
532
549
  end
533
550
  end
@@ -11,32 +11,53 @@ class Puppet::Configurer::Downloader
11
11
  files = []
12
12
  begin
13
13
  catalog.apply do |trans|
14
+ unless Puppet[:ignore_plugin_errors]
15
+ # Propagate the first failure associated with the transaction. The any_failed?
16
+ # method returns the first resource status that failed or nil, not a boolean.
17
+ first_failure = trans.any_failed?
18
+ if first_failure
19
+ event = (first_failure.events || []).first
20
+ detail = event ? event.message : 'unknown'
21
+ raise Puppet::Error.new(_("Failed to retrieve %{name}: %{detail}") % { name: name, detail: detail })
22
+ end
23
+ end
24
+
14
25
  trans.changed?.each do |resource|
15
26
  yield resource if block_given?
16
27
  files << resource[:path]
17
28
  end
18
29
  end
19
30
  rescue Puppet::Error => detail
20
- Puppet.log_exception(detail, _("Could not retrieve %{name}: %{detail}") % { name: name, detail: detail })
31
+ if Puppet[:ignore_plugin_errors]
32
+ Puppet.log_exception(detail, _("Could not retrieve %{name}: %{detail}") % { name: name, detail: detail })
33
+ else
34
+ raise detail
35
+ end
21
36
  end
22
37
  files
23
38
  end
24
39
 
25
40
  def initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore)
26
41
  @name, @path, @source, @ignore, @environment, @source_permissions = name, path, source, ignore, environment, source_permissions
27
- end
28
42
 
29
- def catalog
30
- catalog = Puppet::Resource::Catalog.new("PluginSync", @environment)
31
- catalog.host_config = false
32
- catalog.add_resource(file)
33
- catalog
34
43
  end
35
44
 
36
45
  def file
37
- args = default_arguments.merge(:path => path, :source => source)
38
- args[:ignore] = ignore.split if ignore
39
- Puppet::Type.type(:file).new(args)
46
+ unless @file
47
+ args = default_arguments.merge(:path => path, :source => source)
48
+ args[:ignore] = ignore.split if ignore
49
+ @file = Puppet::Type.type(:file).new(args)
50
+ end
51
+ @file
52
+ end
53
+
54
+ def catalog
55
+ unless @catalog
56
+ @catalog = Puppet::Resource::Catalog.new("PluginSync", @environment)
57
+ @catalog.host_config = false
58
+ @catalog.add_resource(file)
59
+ end
60
+ @catalog
40
61
  end
41
62
 
42
63
  private
@@ -1894,7 +1894,6 @@ EOT
1894
1894
  is used for retrieval, so anything that is a valid file source can
1895
1895
  be used here.",
1896
1896
  },
1897
-
1898
1897
  :pluginsync => {
1899
1898
  :default => true,
1900
1899
  :type => :boolean,
@@ -1908,6 +1907,13 @@ EOT
1908
1907
  :pluginsignore => {
1909
1908
  :default => ".svn CVS .git .hg",
1910
1909
  :desc => "What files to ignore when pulling down plugins.",
1910
+ },
1911
+ :ignore_plugin_errors => {
1912
+ :default => true,
1913
+ :type => :boolean,
1914
+ :desc => "Whether the puppet run should ignore errors during pluginsync. If the setting
1915
+ is false and there are errors during pluginsync, then the agent will abort the run and
1916
+ submit a report containing information about the failed run."
1911
1917
  }
1912
1918
  )
1913
1919
 
@@ -16,14 +16,13 @@ class Puppet::FileServing::Mount::Locales < Puppet::FileServing::Mount
16
16
  def search(relative_path, request)
17
17
  # We currently only support one kind of search on locales - return
18
18
  # them all.
19
- Puppet.debug("Warning: calling Locales.search with empty module path.") if request.environment.modules.empty?
20
19
  paths = request.environment.modules.find_all { |mod| mod.locales? }.collect { |mod| mod.locale_directory }
21
20
  if paths.empty?
22
21
  # If the modulepath is valid then we still need to return a valid root
23
22
  # directory for the search, but make sure nothing inside it is
24
23
  # returned.
25
24
  request.options[:recurse] = false
26
- request.environment.modulepath.empty? ? nil : request.environment.modulepath
25
+ request.environment.modulepath.empty? ? [Puppet[:codedir]] : request.environment.modulepath
27
26
  else
28
27
  paths
29
28
  end
@@ -16,14 +16,13 @@ class Puppet::FileServing::Mount::PluginFacts < Puppet::FileServing::Mount
16
16
  def search(relative_path, request)
17
17
  # We currently only support one kind of search on plugins - return
18
18
  # them all.
19
- Puppet.debug("Warning: calling Plugins.search with empty module path.") if request.environment.modules.empty?
20
19
  paths = request.environment.modules.find_all { |mod| mod.pluginfacts? }.collect { |mod| mod.plugin_fact_directory }
21
20
  if paths.empty?
22
21
  # If the modulepath is valid then we still need to return a valid root
23
22
  # directory for the search, but make sure nothing inside it is
24
23
  # returned.
25
24
  request.options[:recurse] = false
26
- request.environment.modulepath.empty? ? nil : request.environment.modulepath
25
+ request.environment.modulepath.empty? ? [Puppet[:codedir]] : request.environment.modulepath
27
26
  else
28
27
  paths
29
28
  end
@@ -16,14 +16,13 @@ class Puppet::FileServing::Mount::Plugins < Puppet::FileServing::Mount
16
16
  def search(relative_path, request)
17
17
  # We currently only support one kind of search on plugins - return
18
18
  # them all.
19
- Puppet.debug("Warning: calling Plugins.search with empty module path.") if request.environment.modules.empty?
20
19
  paths = request.environment.modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory }
21
20
  if paths.empty?
22
21
  # If the modulepath is valid then we still need to return a valid root
23
22
  # directory for the search, but make sure nothing inside it is
24
23
  # returned.
25
24
  request.options[:recurse] = false
26
- request.environment.modulepath.empty? ? nil : request.environment.modulepath
25
+ request.environment.modulepath.empty? ? [Puppet[:codedir]] : request.environment.modulepath
27
26
  else
28
27
  paths
29
28
  end
@@ -991,12 +991,17 @@ Puppet::Functions.create_function(:new, Puppet::Functions::InternalFunction) do
991
991
 
992
992
  def new_instance(scope, t, *args)
993
993
  return args[0] if args.size == 1 && !t.is_a?(Puppet::Pops::Types::PInitType) && t.instance?(args[0])
994
- result = assert_type(t, new_function_for_type(t, scope).call(scope, *args))
994
+ result = assert_type(t, new_function_for_type(t).call(scope, *args))
995
995
  return block_given? ? yield(result) : result
996
996
  end
997
997
 
998
- def new_function_for_type(t, scope)
999
- @new_function_cache ||= Hash.new() {|hsh, key| hsh[key] = key.new_function.new(scope, loader) }
998
+ def new_function_for_type(t)
999
+ @new_function_cache ||= {}
1000
+
1001
+ unless @new_function_cache.key?(t)
1002
+ @new_function_cache[t] = t.new_function.new(nil, loader)
1003
+ end
1004
+
1000
1005
  @new_function_cache[t]
1001
1006
  end
1002
1007
 
@@ -84,7 +84,7 @@ Puppet::Functions.create_function(:reverse_each) do
84
84
 
85
85
  def reverse_each(iterable)
86
86
  # produces an Iterable
87
- Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable).reverse_each
87
+ Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable, true).reverse_each
88
88
  end
89
89
 
90
90
  def reverse_each_block(iterable, &block)
@@ -88,7 +88,7 @@ Puppet::Functions.create_function(:step) do
88
88
 
89
89
  def step(iterable, step)
90
90
  # produces an Iterable
91
- Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable).step(step)
91
+ Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable, true).step(step)
92
92
  end
93
93
 
94
94
  def step_block(iterable, step, &block)
@@ -1,6 +1,10 @@
1
1
  require 'puppet/indirector/terminus'
2
2
  require 'hiera/scope'
3
3
 
4
+ # This class can't be collapsed into Puppet::Indirector::DataBindings::Hiera
5
+ # because some community plugins rely on this class directly, see PUP-1843.
6
+ # This class is deprecated and will be deleted in a future release.
7
+ # Use `Puppet::DataBinding.indirection.terminus(:hiera)` instead.
4
8
  class Puppet::Indirector::Hiera < Puppet::Indirector::Terminus
5
9
  def initialize(*args)
6
10
  if ! Puppet.features.hiera?
@@ -285,7 +285,7 @@ class Puppet::Node::Environment
285
285
  # @param name [String] The module name
286
286
  # @return [Puppet::Module, nil] The module if found, else nil
287
287
  def module(name)
288
- modules.find {|mod| mod.name == name}
288
+ modules_by_name[name]
289
289
  end
290
290
 
291
291
  # Locate a module instance by the full forge name (EG authorname/module)
@@ -340,6 +340,12 @@ class Puppet::Node::Environment
340
340
  @modules
341
341
  end
342
342
 
343
+ # @api private
344
+ def modules_by_name
345
+ @modules_by_name ||= Hash[modules.map { |mod| [mod.name, mod] }]
346
+ end
347
+ private :modules_by_name
348
+
343
349
  # Generate a warning if the given directory in a module path entry is named `lib`.
344
350
  #
345
351
  # @api private
@@ -44,15 +44,10 @@ module Puppet::Parser::Functions
44
44
  # @api private
45
45
  class AnonymousModuleAdapter < Puppet::Pops::Adaptable::Adapter
46
46
  attr_accessor :module
47
- end
48
47
 
49
- # Get the module that functions are mixed into corresponding to an
50
- # environment
51
- #
52
- # @api private
53
- def self.environment_module(env)
54
- AnonymousModuleAdapter.adapt(env) do |a|
55
- a.module ||= Module.new do
48
+ def self.create_adapter(env)
49
+ adapter = super(env)
50
+ adapter.module = Module.new do
56
51
  @metadata = {}
57
52
 
58
53
  def self.all_function_info
@@ -67,7 +62,16 @@ module Puppet::Parser::Functions
67
62
  @metadata[name] = info
68
63
  end
69
64
  end
70
- end.module
65
+ adapter
66
+ end
67
+ end
68
+
69
+ # Get the module that functions are mixed into corresponding to an
70
+ # environment
71
+ #
72
+ # @api private
73
+ def self.environment_module(env)
74
+ AnonymousModuleAdapter.adapt(env).module
71
75
  end
72
76
 
73
77
  # Create a new Puppet DSL function.
@@ -69,11 +69,7 @@ module Adaptable
69
69
  #
70
70
  def self.get(o)
71
71
  attr_name = self_attr_name
72
- if o.instance_variable_defined?(attr_name)
73
- o.instance_variable_get(attr_name)
74
- else
75
- nil
76
- end
72
+ o.instance_variable_get(attr_name)
77
73
  end
78
74
 
79
75
  # Returns an existing adapter for the given object, or creates a new adapter if the
@@ -94,17 +90,16 @@ module Adaptable
94
90
  #
95
91
  def self.adapt(o, &block)
96
92
  attr_name = self_attr_name
97
- adapter = if o.instance_variable_defined?(attr_name) && value = o.instance_variable_get(attr_name)
93
+ adapter = if value = o.instance_variable_get(attr_name)
98
94
  value
99
95
  else
100
96
  associate_adapter(create_adapter(o), o)
101
97
  end
102
98
  if block_given?
103
- case block.arity
104
- when 1
105
- block.call(adapter)
106
- else
107
- block.call(adapter, o)
99
+ if block.arity == 1
100
+ block.call(adapter)
101
+ else
102
+ block.call(adapter, o)
108
103
  end
109
104
  end
110
105
  adapter
@@ -130,8 +125,7 @@ module Adaptable
130
125
  def self.adapt_new(o, &block)
131
126
  adapter = associate_adapter(create_adapter(o), o)
132
127
  if block_given?
133
- case block.arity
134
- when 1
128
+ if block.arity == 1
135
129
  block.call(adapter)
136
130
  else
137
131
  block.call(adapter, o)