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

[Bug Report] Optional attributes are always null #242

Closed
aka-momo opened this issue Sep 16, 2020 · 0 comments · Fixed by #248
Closed

[Bug Report] Optional attributes are always null #242

aka-momo opened this issue Sep 16, 2020 · 0 comments · Fixed by #248
Labels
bug Something isn't working verified This issue has been verified.
Milestone

Comments

@aka-momo
Copy link
Contributor

Current Behavior

Output

#<TestOrganizer::Context bar="world">
nil
"world"

Expected Behavior

Output

#<TestOrganizer::Context bar="world" foo="hello">
"hello"
"world"

Steps to Reproduce

require 'active_interactor'

class TestInteractor < ActiveInteractor::Base
  def perform
    context.foo = "hello"
    context.bar = 'world'
  end
end

class TestInteractor::Context < ActiveInteractor::Context::Base
  attribute :foo
  attribute :baz, default: -> { '!' }
end

class TestOrganizer < ActiveInteractor::Organizer::Base
  organize :test_interactor
end

p context = TestOrganizer.perform
p context.foo
p context.bar

Additional Comments

Sometimes we define optional attributes to Organizers, these attributes might be set by a nested interactor. The attached example shows that foo was not set to 'hello' because it was not set in the TestOrganizer.perform call.

I thought that is was related to #236 but it does not seem to fix the issue.

@aka-momo aka-momo added bug Something isn't working unverified This issue has not been verified labels Sep 16, 2020
@aaronmallen aaronmallen added this to the v1.1.0 milestone Oct 4, 2020
@aaronmallen aaronmallen added verified This issue has been verified. and removed unverified This issue has not been verified labels Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working verified This issue has been verified.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants