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.



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

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



397
398
399
# File 'lib/dry/monads/list.rb', line 397

def type
  @type
end

Instance Method Details

#[](*args) ⇒ Object



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

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

#coerce(value) ⇒ Object



407
408
409
# File 'lib/dry/monads/list.rb', line 407

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

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



411
412
413
414
# File 'lib/dry/monads/list.rb', line 411

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