Class: Dry::Struct::Constructor

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/struct/constructor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, options = {}, &block) ⇒ Constructor



15
16
17
18
# File 'lib/dry/struct/constructor.rb', line 15

def initialize(type, options = {}, &block)
  @type = type
  @fn = options.fetch(:fn, block)
end

Instance Attribute Details

#fn#call (readonly)



7
8
9
# File 'lib/dry/struct/constructor.rb', line 7

def fn
  @fn
end

#type#call (readonly)



10
11
12
# File 'lib/dry/struct/constructor.rb', line 10

def type
  @type
end

Instance Method Details

#call(input) ⇒ Object Also known as: []



22
23
24
# File 'lib/dry/struct/constructor.rb', line 22

def call(input)
  type[fn[input]]
end