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.



391
392
393
# File 'lib/dry/monads/list.rb', line 391

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



389
390
391
# File 'lib/dry/monads/list.rb', line 389

def type
  @type
end

Instance Method Details

#[](*args) ⇒ Object



395
396
397
# File 'lib/dry/monads/list.rb', line 395

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

#coerce(value) ⇒ Object



399
400
401
# File 'lib/dry/monads/list.rb', line 399

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

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



403
404
405
406
# File 'lib/dry/monads/list.rb', line 403

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