Class: WSDL::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/config.rb

Overview

Runtime configuration for Client and Operation instances.

Controls request validation strictness and resource limits at call time. Parse-time options (sandbox_paths, etc.) belong on parse instead.

Examples:

Create with defaults

config = WSDL::Config.new

Override specific settings

config = WSDL::Config.new(strictness: { request_validation: false })

Derive a modified copy

relaxed = config.with(strictness: false)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strictness: nil, limits: nil) ⇒ Config

Returns a new instance of Config.

Parameters:

  • strictness (Strictness, Hash, Boolean, nil) (defaults to: nil)

    strictness settings. Accepts a Strictness object, a Hash of settings, true (all strict), false (all relaxed), or nil (defaults to all strict).

  • limits (Limits, nil) (defaults to: nil)

    resource limits for request validation. If nil, uses Limits defaults.



26
27
28
29
30
31
# File 'lib/wsdl/config.rb', line 26

def initialize(strictness: nil, limits: nil)
  @strictness = Strictness.resolve(strictness) || Strictness.new
  @limits = Limits.resolve(limits) || Limits.new

  freeze
end

Instance Attribute Details

#limitsLimits (readonly)

Returns resource limits for request validation.

Returns:

  • (Limits)

    resource limits for request validation



37
38
39
# File 'lib/wsdl/config.rb', line 37

def limits
  @limits
end

#strictnessStrictness (readonly)

Returns strictness settings for request validation.

Returns:

  • (Strictness)

    strictness settings for request validation



34
35
36
# File 'lib/wsdl/config.rb', line 34

def strictness
  @strictness
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Returns true if equal.

Parameters:

  • other (Object)

    the object to compare

Returns:

  • (Boolean)

    true if equal



66
67
68
69
70
# File 'lib/wsdl/config.rb', line 66

def ==(other)
  return false unless other.is_a?(Config)

  to_h == other.to_h
end

#hashInteger

Returns the hash code.

Returns:

  • (Integer)

    the hash code



75
76
77
# File 'lib/wsdl/config.rb', line 75

def hash
  to_h.hash
end

#inspectString

Returns human-readable representation.

Returns:

  • (String)

    human-readable representation



80
81
82
83
# File 'lib/wsdl/config.rb', line 80

def inspect
  parts = to_h.map { |key, value| "#{key}=#{value.inspect}" }.join(' ')
  "#<#{self.class.name} #{parts}>"
end

#to_hHash{Symbol => Object}

Returns the config as a hash.

Returns:

  • (Hash{Symbol => Object})

    the config as a hash



57
58
59
60
61
62
# File 'lib/wsdl/config.rb', line 57

def to_h
  {
    strictness: @strictness,
    limits: @limits
  }
end

#with(**options) ⇒ Config

Creates a new Config with some values changed.

Examples:

relaxed = config.with(strictness: false)

Parameters:

  • options (Hash)

    the settings to override

Options Hash (**options):

Returns:

  • (Config)

    a new Config instance with the specified changes



49
50
51
52
53
54
# File 'lib/wsdl/config.rb', line 49

def with(**options)
  self.class.new(
    strictness: options.fetch(:strictness, @strictness),
    limits: options.fetch(:limits, @limits)
  )
end