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.



401
402
403
# File 'lib/dry/monads/list.rb', line 401

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



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

def type
  @type
end

Instance Method Details

#[](*args) ⇒ Object



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

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

#coerce(value) ⇒ Object



409
410
411
# File 'lib/dry/monads/list.rb', line 409

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

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



413
414
415
416
# File 'lib/dry/monads/list.rb', line 413

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