Class: Serega::SeregaConfig::HashAccessConfig
- Inherits:
-
Object
- Object
- Serega::SeregaConfig::HashAccessConfig
- Defined in:
- lib/serega/config.rb
Overview
Config for the hash_access: attribute option
Instance Attribute Summary collapse
-
#opts ⇒ Hash
readonly
Hash_access config options.
Instance Method Summary collapse
-
#default_allow_missing_key ⇒ Boolean
Allow_missing_key used when an attribute omits it.
-
#default_allow_missing_key=(value) ⇒ Boolean
Sets the allow_missing_key used when an attribute omits it.
-
#default_mode ⇒ Symbol
Mode used by
hash_access: true(default :symbol). -
#default_mode=(value) ⇒ Symbol
Sets the mode used by
hash_access: true. -
#initialize(opts) ⇒ Serega::SeregaConfig::HashAccessConfig
constructor
Initializes HashAccessConfig object.
Constructor Details
#initialize(opts) ⇒ Serega::SeregaConfig::HashAccessConfig
Initializes HashAccessConfig object
277 278 279 |
# File 'lib/serega/config.rb', line 277 def initialize(opts) @opts = opts end |
Instance Attribute Details
#opts ⇒ Hash (readonly)
Returns hash_access config options.
268 269 270 |
# File 'lib/serega/config.rb', line 268 def opts @opts end |
Instance Method Details
#default_allow_missing_key ⇒ Boolean
Returns allow_missing_key used when an attribute omits it.
298 299 300 |
# File 'lib/serega/config.rb', line 298 def default_allow_missing_key opts.fetch(:default_allow_missing_key) end |
#default_allow_missing_key=(value) ⇒ Boolean
Sets the allow_missing_key used when an attribute omits it
305 306 307 308 309 310 311 |
# File 'lib/serega/config.rb', line 305 def default_allow_missing_key=(value) unless value == true || value == false raise SeregaError, "Invalid hash_access default_allow_missing_key #{value.inspect}. Must be a Boolean" end opts[:default_allow_missing_key] = value end |
#default_mode ⇒ Symbol
Returns mode used by hash_access: true (default :symbol).
282 283 284 |
# File 'lib/serega/config.rb', line 282 def default_mode opts.fetch(:default_mode) end |
#default_mode=(value) ⇒ Symbol
Sets the mode used by hash_access: true
289 290 291 292 293 294 295 |
# File 'lib/serega/config.rb', line 289 def default_mode=(value) unless AttributeValueResolvers::HashAccessResolver::MODES.include?(value) raise SeregaError, "Invalid hash_access default_mode #{value.inspect}. Allowed modes: :symbol, :string" end opts[:default_mode] = value end |