Module: Familia::Settings
- Included in:
- Familia, DataType, Horreum::DefinitionMethods
- Defined in:
- lib/familia/settings.rb
Overview
Familia::Settings
Instance Attribute Summary collapse
- #current_key_version(val = nil) ⇒ Object
- #default_expiration(v = nil) ⇒ Object
- #delim(val = nil) ⇒ Object
- #encryption_keys(val = nil) ⇒ Object
-
#encryption_personalization(val = nil) ⇒ String
Personalization string for BLAKE2b key derivation in XChaCha20Poly1305.
- #logical_database(v = nil) ⇒ Object
- #prefix(val = nil) ⇒ Object
-
#schema_path(val = nil) ⇒ String, ...
Directory containing schema files for JSON Schema validation.
-
#schema_validator(val = nil) ⇒ Symbol, Object
Validator type for JSON Schema validation.
-
#schemas(val = nil) ⇒ Hash
Hash mapping class names to their schema file paths.
-
#strict_write_order(val = nil) ⇒ Boolean
Controls whether collection writes on a DataType raise an error when the parent Horreum object has unsaved scalar field changes.
- #suffix(val = nil) ⇒ Object
-
#transaction_mode(val = nil) ⇒ Symbol
Controls transaction behavior when connection handlers don't support transactions.
Instance Method Summary collapse
-
#configure {|Settings| ... } ⇒ Settings
(also: #config)
Configure Familia settings.
-
#default_suffix ⇒ Object
We define this do-nothing method because it reads better than simply Familia.suffix in some contexts.
-
#pipelined_mode(val = nil) ⇒ Symbol
Controls pipeline behavior when connection handlers don't support pipelines.
- #pipelined_mode=(val) ⇒ Object
Instance Attribute Details
#current_key_version(val = nil) ⇒ Object
68 69 70 71 |
# File 'lib/familia/settings.rb', line 68 def current_key_version(val = nil) @current_key_version = val if val @current_key_version end |
#default_expiration(v = nil) ⇒ Object
46 47 48 49 |
# File 'lib/familia/settings.rb', line 46 def default_expiration(v = nil) @default_expiration = v unless v.nil? @default_expiration end |
#delim(val = nil) ⇒ Object
31 32 33 34 |
# File 'lib/familia/settings.rb', line 31 def delim(val = nil) @delim = val if val @delim end |
#encryption_keys(val = nil) ⇒ Object
63 64 65 66 |
# File 'lib/familia/settings.rb', line 63 def encryption_keys(val = nil) @encryption_keys = val if val @encryption_keys end |
#encryption_personalization(val = nil) ⇒ String
Personalization string for BLAKE2b key derivation in XChaCha20Poly1305. This provides cryptographic domain separation, ensuring derived keys are unique per application even with identical master keys and contexts. Must be 16 bytes or less (automatically padded with null bytes).
end
84 85 86 87 88 89 90 91 |
# File 'lib/familia/settings.rb', line 84 def encryption_personalization(val = nil) if val raise ArgumentError, 'Personalization string cannot exceed 16 bytes' if val.bytesize > 16 @encryption_personalization = val end @encryption_personalization end |
#logical_database(v = nil) ⇒ Object
51 52 53 54 55 |
# File 'lib/familia/settings.rb', line 51 def logical_database(v = nil) Familia.trace :DB, nil, "#{@logical_database} #{v}" if Familia.debug? @logical_database = v unless v.nil? @logical_database end |
#prefix(val = nil) ⇒ Object
36 37 38 39 |
# File 'lib/familia/settings.rb', line 36 def prefix(val = nil) @prefix = val if val @prefix end |
#schema_path(val = nil) ⇒ String, ...
Directory containing schema files for JSON Schema validation. When set, schema files are discovered by convention using the underscored class name (e.g., Customer -> customer.json).
181 182 183 184 |
# File 'lib/familia/settings.rb', line 181 def schema_path(val = nil) @schema_path = val if val @schema_path end |
#schema_validator(val = nil) ⇒ Symbol, Object
Validator type for JSON Schema validation.
Available options:
- :json_schemer (default): Use the json_schemer gem for validation
- :none: Disable schema validation entirely
- Custom instance: Any object responding to #validate
220 221 222 223 |
# File 'lib/familia/settings.rb', line 220 def schema_validator(val = nil) @schema_validator = val if val @schema_validator || :json_schemer end |
#schemas(val = nil) ⇒ Hash
Hash mapping class names to their schema file paths. Takes precedence over convention-based discovery via schema_path.
200 201 202 203 |
# File 'lib/familia/settings.rb', line 200 def schemas(val = nil) @schemas = val if val @schemas || {} end |
#strict_write_order(val = nil) ⇒ Boolean
Controls whether collection writes on a DataType raise an error when the parent Horreum object has unsaved scalar field changes.
When false (default), a warning is emitted via Familia.warn. When true, a Familia::Problem exception is raised.
164 165 166 167 |
# File 'lib/familia/settings.rb', line 164 def strict_write_order(val = nil) @strict_write_order = val unless val.nil? @strict_write_order || false end |
#suffix(val = nil) ⇒ Object
41 42 43 44 |
# File 'lib/familia/settings.rb', line 41 def suffix(val = nil) @suffix = val if val @suffix end |
#transaction_mode(val = nil) ⇒ Symbol
Controls transaction behavior when connection handlers don't support transactions
Available modes:
- :warn (default): Log warning and execute commands individually
- :strict: Raise OperationModeError when transaction unavailable
- :permissive: Silently execute commands individually
108 109 110 111 112 113 114 115 116 |
# File 'lib/familia/settings.rb', line 108 def transaction_mode(val = nil) if val unless [:strict, :warn, :permissive].include?(val) raise ArgumentError, 'Transaction mode must be :strict, :warn, or :permissive' end @transaction_mode = val end @transaction_mode || :warn # default to warn mode end |
Instance Method Details
#configure {|Settings| ... } ⇒ Settings Also known as: config
Configure Familia settings
238 239 240 241 |
# File 'lib/familia/settings.rb', line 238 def configure yield self if block_given? self end |
#default_suffix ⇒ Object
We define this do-nothing method because it reads better than simply Familia.suffix in some contexts.
59 60 61 |
# File 'lib/familia/settings.rb', line 59 def default_suffix suffix end |
#pipelined_mode(val = nil) ⇒ Symbol
Controls pipeline behavior when connection handlers don't support pipelines
Available modes:
- :warn (default): Log warning and execute commands individually
- :strict: Raise OperationModeError when pipeline unavailable
- :permissive: Silently execute commands individually
133 134 135 136 137 138 139 140 141 |
# File 'lib/familia/settings.rb', line 133 def pipelined_mode(val = nil) if val unless [:strict, :warn, :permissive].include?(val) raise ArgumentError, 'Pipeline mode must be :strict, :warn, or :permissive' end @pipelined_mode = val end @pipelined_mode || :warn # default to warn mode end |
#pipelined_mode=(val) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/familia/settings.rb', line 143 def pipelined_mode=(val) unless [:strict, :warn, :permissive].include?(val) raise ArgumentError, 'Pipeline mode must be :strict, :warn, or :permissive' end @pipelined_mode = val end |