Skip to content

Instance variables are kept across SO invocation #21

@thebigw4lrus

Description

@thebigw4lrus

Context

Declarations of instance variables within a SO.

Problem

Instances variables are kept across SO invocation. It is only reproduce-able when an inline dependency is declared like:

dependency :something, class: SomeClass

How to Reproduce it

class Example::Resolver
  include Injectable

  argument :value

  def call
    result
  end

  private

  def result
    @variable ||= value
  end
end


class Example::Caller
  include Injectable

  dependency :resolver, class: Example::Resolver

  def call
    puts "Result 1 -> #{resolver.call(value: 1)}"
    puts "Result 2 -> #{resolver.call(value: 2)}"
  end
end

> Example::Caller.call
Result 1 -> 1
Result 2 -> 1
=> nil

Note: When the dependency is declared like dependency(:resolver) { Example::Resolver } this does not happen, and all instances variables are cleared up after across execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalidThis doesn't seem rightquestionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions