Project

General

Profile

Feature #12971

(Refactoring) Remove `defined?` checks from observer.rb

Added by itsNikolay (Nikolay Ponomarev) almost 3 years ago. Updated almost 3 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:78259]

Description

Remove defined? checks from observer.rb

  • Contains less code
  • Easier to understand Observable logic
  • No performance downgrade

History

Updated by itsNikolay (Nikolay Ponomarev) almost 3 years ago

can be closed also =\

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

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

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

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

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Description updated (diff)

Also available in: Atom PDF