Module: GraphMediator::Proxy::ClassMethods

Defined in:
lib/graph_mediator.rb

Instance Method Summary collapse

Instance Method Details

#currently_mediating?(ids) ⇒ Boolean

True if we are currently mediating instances of any of the passed ids.

Returns:

  • (Boolean)


179
180
181
182
183
# File 'lib/graph_mediator.rb', line 179

def currently_mediating?(ids)
  Array(ids).detect do |id|
    mediators[id] || mediators_for_new_records.find { |m| m.mediated_id == id }
  end
end

#disable_all_mediation!Object

Turn off mediation for all instances of this class. (Off by default)

This will cause new mediators to start up disabled, but existing mediators will finish normally.



169
170
171
# File 'lib/graph_mediator.rb', line 169

def disable_all_mediation!
  self.__graph_mediator_enabled = false
end

#enable_all_mediation!Object

Turn on mediation for all instances of this class. (On by default)



161
162
163
# File 'lib/graph_mediator.rb', line 161

def enable_all_mediation!
  self.__graph_mediator_enabled = true
end

#instances_being_destroyedObject

An array of instance ids currently being in the process of being destroyed.



217
218
219
# File 'lib/graph_mediator.rb', line 217

def instances_being_destroyed
  _generate_thread_local(mediator_being_destroyed_array_key, Array)
end

#mediation_enabled?Boolean

True if mediation is enabled at the class level.

Returns:

  • (Boolean)


174
175
176
# File 'lib/graph_mediator.rb', line 174

def mediation_enabled?
  self.__graph_mediator_enabled
end

#mediator_being_destroyed_array_keyObject

Unique key to access a thread local array of ids of instances that are currently in the process of being deleted.



199
# File 'lib/graph_mediator.rb', line 199

def mediator_being_destroyed_array_key; end

#mediator_hash_keyObject

Unique key to access a thread local hash of mediators for specific #base::MediatorProxy type.

(This is overwritten by GraphMediator._include_new_proxy)



189
# File 'lib/graph_mediator.rb', line 189

def mediator_hash_key; end

#mediator_new_array_keyObject

Unique key to access a thread local array of mediators of new records for specific #base::MediatorProxy type.

(This is overwritten by GraphMediator._include_new_proxy)



195
# File 'lib/graph_mediator.rb', line 195

def mediator_new_array_key; end

#mediatorsObject

The hash of Mediator instances active in this Thread for the Proxy’s base class.

instance.id => Mediator of (instance)



206
207
208
# File 'lib/graph_mediator.rb', line 206

def mediators
  _generate_thread_local(mediator_hash_key, Hash)
end

#mediators_for_new_recordsObject

An array of Mediator instances mediating new records in this Thread for the Proxy’s base class.



212
213
214
# File 'lib/graph_mediator.rb', line 212

def mediators_for_new_records
  _generate_thread_local(mediator_new_array_key, Array)
end