When trying to use a time/date based restriction from a commands macro, the DateTime or Time object passed in as a parameter is converted to an Array and then splatted against the filter method, causing an ArgumentError.
The SQL-relation :requests has a :created_at column, and Requests#expired is defined:
def expired(expiration_time=default_expiration_time)
where{ created_at < expiration_time }
end
The commands macro is used like this:
r = Class.new(ROM::Repository[:requests]) do
commands delete: [:by_pk, :expired]
end.new(rom)
And calling the generated method:
r.delete_expired(Time.now)
#=> ArgumentError: wrong number of arguments (given 10, expected 0..1)
Copied from original issue: rom-rb/rom-repository#93
From @daniels on June 19, 2017 12:27
When trying to use a time/date based restriction from a commands macro, the DateTime or Time object passed in as a parameter is converted to an Array and then splatted against the filter method, causing an ArgumentError.
The SQL-relation
:requests
has a:created_at
column, andRequests#expired
is defined:The commands macro is used like this:
And calling the generated method:
Copied from original issue: rom-rb/rom-repository#93