Issue #12971 has been updated by Nobuyoshi Nakada.


You have to define the instance method, not setting instance variables on `Observable` module.
For example:

```ruby
  module Initializer
    def initialize(*)
      @observer_peers ||= {}
      @observer_state ||= false
      super
    end
  end

  def self.included(mod)
    mod.prepend(Initializer)
    super
  end
```


----------------------------------------
Feature #12971: (Refactoring) Remove `defined?` checks from observer.rb
https://bugs.ruby-lang.org/issues/12971#change-61630

* Author: Nikolay Ponomarev
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Remove `defined?` checks from observer.rb
- Contains less code
- Easier to understand Observable logic
- No performance downgrade



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>