Class: AMQP::Client::Configuration
- Inherits:
-
Object
- Object
- AMQP::Client::Configuration
- Defined in:
- lib/amqp/client/configuration.rb
Overview
Configuration for AMQP::Client
Instance Attribute Summary collapse
-
#codec_registry ⇒ Object
readonly
Returns the value of attribute codec_registry.
-
#default_content_encoding ⇒ String?
Default content encoding for published messages.
-
#default_content_type ⇒ String?
Default content type for published messages.
-
#strict_coding ⇒ Boolean
Whether to raise on unknown codecs.
Instance Method Summary collapse
-
#enable_builtin_codecs ⇒ self
Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding This is a convenience method that delegates to the codec registry.
-
#enable_builtin_coders ⇒ self
Enable built-in coders for common content encodings.
-
#enable_builtin_parsers ⇒ self
Enable built-in parsers for common content types.
-
#initialize(codec_registry) ⇒ Configuration
constructor
Initialize a new configuration.
-
#register_coder(content_encoding:, coder:) ⇒ self
Register a custom coder for a content encoding.
-
#register_parser(content_type:, parser:) ⇒ self
Register a custom parser for a content type.
Constructor Details
#initialize(codec_registry) ⇒ Configuration
Initialize a new configuration
18 19 20 21 22 23 |
# File 'lib/amqp/client/configuration.rb', line 18 def initialize(codec_registry) @codec_registry = codec_registry @strict_coding = false @default_content_type = nil @default_content_encoding = nil end |
Instance Attribute Details
#codec_registry ⇒ Object (readonly)
Returns the value of attribute codec_registry.
14 15 16 |
# File 'lib/amqp/client/configuration.rb', line 14 def codec_registry @codec_registry end |
#default_content_encoding ⇒ String?
Returns Default content encoding for published messages.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/amqp/client/configuration.rb', line 12 class Configuration attr_accessor :strict_coding, :default_content_type, :default_content_encoding attr_reader :codec_registry # Initialize a new configuration # @param codec_registry [MessageCodecRegistry] The codec registry to use def initialize(codec_registry) @codec_registry = codec_registry @strict_coding = false @default_content_type = nil @default_content_encoding = nil end # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding # This is a convenience method that delegates to the codec registry # @return [self] def enable_builtin_codecs codec_registry.enable_builtin_codecs self end # Enable built-in parsers for common content types # @return [self] def enable_builtin_parsers codec_registry.enable_builtin_parsers self end # Enable built-in coders for common content encodings # @return [self] def enable_builtin_coders codec_registry.enable_builtin_coders self end # Register a custom parser for a content type # @param content_type [String] The content_type to match # @param parser [Object] The parser object # @return [self] def register_parser(content_type:, parser:) codec_registry.register_parser(content_type:, parser:) self end # Register a custom coder for a content encoding # @param content_encoding [String] The content_encoding to match # @param coder [Object] The coder object # @return [self] def register_coder(content_encoding:, coder:) codec_registry.register_coder(content_encoding:, coder:) self end end |
#default_content_type ⇒ String?
Returns Default content type for published messages.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/amqp/client/configuration.rb', line 12 class Configuration attr_accessor :strict_coding, :default_content_type, :default_content_encoding attr_reader :codec_registry # Initialize a new configuration # @param codec_registry [MessageCodecRegistry] The codec registry to use def initialize(codec_registry) @codec_registry = codec_registry @strict_coding = false @default_content_type = nil @default_content_encoding = nil end # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding # This is a convenience method that delegates to the codec registry # @return [self] def enable_builtin_codecs codec_registry.enable_builtin_codecs self end # Enable built-in parsers for common content types # @return [self] def enable_builtin_parsers codec_registry.enable_builtin_parsers self end # Enable built-in coders for common content encodings # @return [self] def enable_builtin_coders codec_registry.enable_builtin_coders self end # Register a custom parser for a content type # @param content_type [String] The content_type to match # @param parser [Object] The parser object # @return [self] def register_parser(content_type:, parser:) codec_registry.register_parser(content_type:, parser:) self end # Register a custom coder for a content encoding # @param content_encoding [String] The content_encoding to match # @param coder [Object] The coder object # @return [self] def register_coder(content_encoding:, coder:) codec_registry.register_coder(content_encoding:, coder:) self end end |
#strict_coding ⇒ Boolean
Returns Whether to raise on unknown codecs.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/amqp/client/configuration.rb', line 12 class Configuration attr_accessor :strict_coding, :default_content_type, :default_content_encoding attr_reader :codec_registry # Initialize a new configuration # @param codec_registry [MessageCodecRegistry] The codec registry to use def initialize(codec_registry) @codec_registry = codec_registry @strict_coding = false @default_content_type = nil @default_content_encoding = nil end # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding # This is a convenience method that delegates to the codec registry # @return [self] def enable_builtin_codecs codec_registry.enable_builtin_codecs self end # Enable built-in parsers for common content types # @return [self] def enable_builtin_parsers codec_registry.enable_builtin_parsers self end # Enable built-in coders for common content encodings # @return [self] def enable_builtin_coders codec_registry.enable_builtin_coders self end # Register a custom parser for a content type # @param content_type [String] The content_type to match # @param parser [Object] The parser object # @return [self] def register_parser(content_type:, parser:) codec_registry.register_parser(content_type:, parser:) self end # Register a custom coder for a content encoding # @param content_encoding [String] The content_encoding to match # @param coder [Object] The coder object # @return [self] def register_coder(content_encoding:, coder:) codec_registry.register_coder(content_encoding:, coder:) self end end |
Instance Method Details
#enable_builtin_codecs ⇒ self
Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding This is a convenience method that delegates to the codec registry
28 29 30 31 |
# File 'lib/amqp/client/configuration.rb', line 28 def enable_builtin_codecs codec_registry.enable_builtin_codecs self end |
#enable_builtin_coders ⇒ self
Enable built-in coders for common content encodings
42 43 44 45 |
# File 'lib/amqp/client/configuration.rb', line 42 def enable_builtin_coders codec_registry.enable_builtin_coders self end |
#enable_builtin_parsers ⇒ self
Enable built-in parsers for common content types
35 36 37 38 |
# File 'lib/amqp/client/configuration.rb', line 35 def enable_builtin_parsers codec_registry.enable_builtin_parsers self end |
#register_coder(content_encoding:, coder:) ⇒ self
Register a custom coder for a content encoding
60 61 62 63 |
# File 'lib/amqp/client/configuration.rb', line 60 def register_coder(content_encoding:, coder:) codec_registry.register_coder(content_encoding:, coder:) self end |
#register_parser(content_type:, parser:) ⇒ self
Register a custom parser for a content type
51 52 53 54 |
# File 'lib/amqp/client/configuration.rb', line 51 def register_parser(content_type:, parser:) codec_registry.register_parser(content_type:, parser:) self end |