Class: Bullet::Registry::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bullet/registry/base.rb

Direct Known Subclasses

Association, CallStack, Object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



8
9
10
# File 'lib/bullet/registry/base.rb', line 8

def initialize
  @registry = {}
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



6
7
8
# File 'lib/bullet/registry/base.rb', line 6

def registry
  @registry
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/bullet/registry/base.rb', line 12

def [](key)
  @registry[key]
end

#add(key, value) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/bullet/registry/base.rb', line 28

def add(key, value)
  @registry[key] ||= Set.new
  if value.is_a? Array
    @registry[key] += value
  else
    @registry[key] << value
  end
end

#delete(base) ⇒ Object



20
21
22
# File 'lib/bullet/registry/base.rb', line 20

def delete(base)
  @registry.delete(base)
end

#each(&block) ⇒ Object



16
17
18
# File 'lib/bullet/registry/base.rb', line 16

def each(&block)
  @registry.each(&block)
end

#include?(key, value) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/bullet/registry/base.rb', line 37

def include?(key, value)
  !@registry[key].nil? && @registry[key].include?(value)
end

#select(*args, &block) ⇒ Object



24
25
26
# File 'lib/bullet/registry/base.rb', line 24

def select(*args, &block)
  @registry.select(*args, &block)
end