Sha256: 91d0fc1554559b8c2fadd529fb2084192c6230f185b359b5f6a255d7f87e1a5c

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'active_support/concern'
module Origen
  module Callbacks
    extend ActiveSupport::Concern

    included do
      include Origen::ModelInitializer
    end

    def register_callback_listener # :nodoc:
      Origen.app.add_callback_listener(self)
    end
  end

  # The regular callbacks module will register listeners that expire upon the next target
  # load, normally this is what is wanted at app level since things should start afresh
  # every time the target is loaded.
  #
  # However within Origen core (and possibly some plugins) it is often the case that registered
  # listeners will be objects that are not re-instantiated upon target load and persist for
  # the entire Origen thread. In this case use the CoreCallbacks module instead of the regular
  # Callbacks module to make these objects register as permanent listeners.
  module PersistentCallbacks
    extend ActiveSupport::Concern

    included do
      include Origen::ModelInitializer
    end

    def register_callback_listener # :nodoc:
      Origen.app.add_persistant_callback_listener(self)
    end
  end
  CoreCallbacks = PersistentCallbacks
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
origen-0.0.4 lib/origen/callbacks.rb
origen-0.0.3 lib/origen/callbacks.rb
origen-0.0.2 lib/origen/callbacks.rb