Class: Dry::Monads::List::ListBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/monads/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ ListBuilder

Returns a new instance of ListBuilder.



328
329
330
# File 'lib/dry/monads/list.rb', line 328

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



326
327
328
# File 'lib/dry/monads/list.rb', line 326

def type
  @type
end

Instance Method Details

#[](*args) ⇒ Object



332
333
334
# File 'lib/dry/monads/list.rb', line 332

def [](*args)
  List.new(args, type)
end

#coerce(value) ⇒ Object



336
337
338
# File 'lib/dry/monads/list.rb', line 336

def coerce(value)
  List.coerce(value, type)
end

#pure(val = Undefined, &block) ⇒ Object



340
341
342
343
# File 'lib/dry/monads/list.rb', line 340

def pure(val = Undefined, &block)
  value = Undefined.default(val, block)
  List.pure(value, type)
end