Class: WSDL::Config
- Inherits:
-
Object
- Object
- WSDL::Config
- Defined in:
- lib/wsdl/config.rb
Overview
Behavioral configuration for Client instances.
Groups all parse-time and request-time settings into a single frozen value object. Accepts the same keyword arguments as WSDL::Client#initialize for the behavioral subset (everything except the WSDL source, HTTP adapter, and cache).
Instance Attribute Summary collapse
-
#format_xml ⇒ Boolean
readonly
Whether to format XML output with indentation.
-
#limits ⇒ Limits
readonly
Resource limits for DoS protection.
-
#sandbox_paths ⇒ Array<String>?
readonly
Allowed directories for file access.
-
#strict_schema ⇒ Boolean
readonly
Strict schema handling and request validation mode.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
True if equal.
-
#hash ⇒ Integer
The hash code.
-
#initialize(format_xml: true, strict_schema: true, sandbox_paths: nil, limits: nil) ⇒ Config
constructor
A new instance of Config.
-
#inspect ⇒ String
Human-readable representation.
-
#to_h ⇒ Hash{Symbol => Object}
The config as a hash.
-
#with(**options) ⇒ Config
Creates a new Config with some values changed.
Constructor Details
#initialize(format_xml: true, strict_schema: true, sandbox_paths: nil, limits: nil) ⇒ Config
Returns a new instance of Config.
35 36 37 38 39 40 41 42 43 |
# File 'lib/wsdl/config.rb', line 35 def initialize(format_xml: true, strict_schema: true, sandbox_paths: nil, limits: nil) @format_xml = format_xml @strict_schema = strict_schema ? true : false @sandbox_paths = sandbox_paths @limits = limits || WSDL.limits freeze end |
Instance Attribute Details
#format_xml ⇒ Boolean (readonly)
Returns whether to format XML output with indentation.
46 47 48 |
# File 'lib/wsdl/config.rb', line 46 def format_xml @format_xml end |
#limits ⇒ Limits (readonly)
Returns resource limits for DoS protection.
55 56 57 |
# File 'lib/wsdl/config.rb', line 55 def limits @limits end |
#sandbox_paths ⇒ Array<String>? (readonly)
Returns allowed directories for file access.
52 53 54 |
# File 'lib/wsdl/config.rb', line 52 def sandbox_paths @sandbox_paths end |
#strict_schema ⇒ Boolean (readonly)
Returns strict schema handling and request validation mode.
49 50 51 |
# File 'lib/wsdl/config.rb', line 49 def strict_schema @strict_schema end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Returns true if equal.
90 91 92 93 94 |
# File 'lib/wsdl/config.rb', line 90 def ==(other) return false unless other.is_a?(Config) to_h == other.to_h end |
#hash ⇒ Integer
Returns the hash code.
99 100 101 |
# File 'lib/wsdl/config.rb', line 99 def hash to_h.hash end |
#inspect ⇒ String
Returns human-readable representation.
104 105 106 107 |
# File 'lib/wsdl/config.rb', line 104 def inspect parts = to_h.map { |key, value| "#{key}=#{value.inspect}" }.join(' ') "#<#{self.class.name} #{parts}>" end |
#to_h ⇒ Hash{Symbol => Object}
Returns the config as a hash.
79 80 81 82 83 84 85 86 |
# File 'lib/wsdl/config.rb', line 79 def to_h { format_xml: @format_xml, strict_schema: @strict_schema, sandbox_paths: @sandbox_paths, limits: @limits } end |
#with(**options) ⇒ Config
Creates a new Config with some values changed.
69 70 71 72 73 74 75 76 |
# File 'lib/wsdl/config.rb', line 69 def with(**) self.class.new( format_xml: .fetch(:format_xml, @format_xml), strict_schema: .fetch(:strict_schema, @strict_schema), sandbox_paths: .fetch(:sandbox_paths, @sandbox_paths), limits: .fetch(:limits, @limits) ) end |