Class: Dumpling::Registry
- Inherits:
-
Object
- Object
- Dumpling::Registry
- Defined in:
- lib/dumpling/registry.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #get(id) ⇒ Object
- #has?(id) ⇒ Boolean
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #initialize_dup(original) ⇒ Object
- #set(id, value) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 8 |
# File 'lib/dumpling/registry.rb', line 5 def initialize @data = {} @keys = Set.new end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
3 4 5 |
# File 'lib/dumpling/registry.rb', line 3 def keys @keys end |
Instance Method Details
#get(id) ⇒ Object
15 16 17 |
# File 'lib/dumpling/registry.rb', line 15 def get(id) @data[id] end |
#has?(id) ⇒ Boolean
19 20 21 |
# File 'lib/dumpling/registry.rb', line 19 def has?(id) @keys.include?(id) end |
#initialize_dup(original) ⇒ Object
23 24 25 26 27 |
# File 'lib/dumpling/registry.rb', line 23 def initialize_dup(original) @data = original.data.dup @keys = original.keys.dup super end |
#set(id, value) ⇒ Object
10 11 12 13 |
# File 'lib/dumpling/registry.rb', line 10 def set(id, value) @keys << id @data[id] = value end |