Class: Dry::Initializer::Struct

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/dry/initializer/struct.rb

Constant Summary

Constants included from Dry::Initializer

VERSION

Instance Attribute Summary

Attributes included from DSL

#null

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dry::Initializer

dry_initializer, option, param

Methods included from DSL

#[], #define

Class Method Details

.new(options) ⇒ Object Also known as: call



13
14
15
# File 'lib/dry/initializer/struct.rb', line 13

def new(options)
  super(**Hash(options).each_with_object({}) { |(k, v), h| h[k.to_sym] = v })
end

Instance Method Details

#to_hHash<String, ...>

Represents event data as a nested hash with deeply stringified keys

Returns:

  • (Hash<String, ...>)


23
24
25
26
27
28
29
# File 'lib/dry/initializer/struct.rb', line 23

def to_h
  self
    .class
    .dry_initializer
    .attributes(self)
    .each_with_object({}) { |(k, v), h| h[k.to_s] = __hashify(v) }
end