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

Using display as property name on Context #183

Open
lenart opened this issue Mar 13, 2020 · 0 comments
Open

Using display as property name on Context #183

lenart opened this issue Mar 13, 2020 · 0 comments

Comments

@lenart
Copy link

lenart commented Mar 13, 2020

I stumbled across this issue during specs where I named a property on the Context object display. The results were surprising and, after some code reading, it turns out it has to do with the way OpenStruct lazy-loads/queries properties.

Sample class

class SampleInteractor
  include Interactor

  def call
    context.display = 'Foobar'
  end
end

Expected

SampleInteractor.call.display # => 'Foobar'

Actual

SampleInteractor.call.display # => #<Interactor::Context display="Foobar">nil

As mentioned this problem is in using OpenStruct where the same behavior can be observed and it's all because there is already Object#display defined on Object.

Maybe something worth adding to the docs as a caveat?

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

No branches or pull requests

1 participant