Class: Bullet::Registry::Base
Direct Known Subclasses
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add(key, value) ⇒ Object
- #delete(base) ⇒ Object
- #each(&block) ⇒ Object
- #include?(key, value) ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #select(*args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/bullet/registry/base.rb', line 6 def initialize @registry = {} end |
Instance Attribute Details
#registry ⇒ Object (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
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 |