Ok I’m not sure what happened with my last topic so I created a new one.
The question is - something has changed lately that I cannot pass more params than the first one defined in a call when using bind method in monads? Take a look.
require 'dry-monads'
require 'dry/monads/all'
module Test
class MonadsClass
include Dry::Monads
def initialize(signees)
@signees = signees
end
def call
Success(signees)
.bind(method(:fetch_template))
.bind(method(:envelope_from_template))
end
attr_reader :signees
private
def fetch_template(signees)
key = "template_#{signees.size}".to_sym
template_id = Rails.application.credentials.some_api.fetch(key)
Success(template_id: template_id, key: key)
end
def envelope_from_template(template_id:, key:)
response = some_api.copy_from_template(template_id, key)
response.failure? ? Failure(response.failure) : Success(response.value!)
end
end
end
Which gives me a strange error of:
Failure/Error:
def envelope_from_template(template_id:, key:)
response = namirial_api.copy_from_template(template_id)
response.failure? ? Failure(response.failure) : Success(response.value!)
end
ArgumentError:
wrong number of arguments (given 1, expected 0; required keywords: template_id, key)
Am I missed something?