Class: Dumpling::Registry

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

Direct Known Subclasses

TestRegistry

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Returns:

  • (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