Class: Bullet::Registry::Base

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

Direct Known Subclasses

Association, Object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



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

def initialize
  @registry = {}
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



4
5
6
# File 'lib/bullet/registry/base.rb', line 4

def registry
  @registry
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/bullet/registry/base.rb', line 10

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

#add(key, value) ⇒ Object



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

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



18
19
20
# File 'lib/bullet/registry/base.rb', line 18

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

#each(&block) ⇒ Object



14
15
16
# File 'lib/bullet/registry/base.rb', line 14

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

#include?(key, value) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/bullet/registry/base.rb', line 35

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

#select(*args, &block) ⇒ Object



22
23
24
# File 'lib/bullet/registry/base.rb', line 22

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