Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow set operation to take a lambda #128

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jrmhaig
Copy link
Collaborator

@jrmhaig jrmhaig commented Jun 30, 2024

The set pre-processing operation will currently set a field to a static value. Issue #112 suggests allowing the field to be set according to a parameter passed to ameoba_dup.

set can now be defined to use the return value of a lambda and keyword arguments can be used on amoeba_dup to specify arguments to the lambdas:

class Test < ActiveRecord::Base
  amoeba do
    set test_field: ->(arg:) { arg }
  end
end

t1 = Test.new
t2 = t1.amoeba_dup(arg: 123)
t2.test_field
# => 123

Note that the @options instance variable on the macro classes has been removed. It is not at all clear what was the purpose of this instance variable as it did not appear to be set anywhere and its removal has not affected any of the unit tests.

@coveralls
Copy link

Coverage Status

coverage: 93.38% (-1.9%) from 95.324%
when pulling b1b59e7 on jrmhaig:amoeba_params
into 6adbbc5 on amoeba-rb:master.

@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@coveralls
Copy link

Coverage Status

coverage: 93.38% (-1.9%) from 95.324%
when pulling ff08351 on jrmhaig:amoeba_params
into 6adbbc5 on amoeba-rb:master.

@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
@amoeba-rb amoeba-rb deleted a comment from coveralls Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants