-
Notifications
You must be signed in to change notification settings - Fork 136
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
Assigning attributes can nil them out #47
Labels
Comments
Only happens the first time: class Interaction < ActiveInteraction::Base
boolean :a
def execute
a = false
a = a
end
end
p Interaction.run!(a: true)
# => false |
Getting more confused: class Interaction < ActiveInteraction::Base
boolean :a
def execute
b = a
a = b
end
end
p Interaction.run!(a: true)
# => true |
Adding class Interaction < ActiveInteraction::Base
boolean :a
def execute; a = self.a end
end
p Interaction.run!(a: true)
# => true |
Turns out this is not a bug against ActiveInteraction — it's just weird Ruby behavior! class Klass
def initialize; @thing = 'swamp' end
def thing; @thing end
def thing=(other) @thing = other end
def test1; thing = thing end
def test2; self.thing = thing end
def test3; thing = self.thing end
end
klass = Klass.new
p klass.test1 # => nil
p klass.test2 # => "swamp"
p klass.test3 # => "swamp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is distressing, to say the least:
The text was updated successfully, but these errors were encountered: