Skip to content

Using display as property name on Context #183

Description

@lenart

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions