Class: LintTrap::Registry

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

Overview

Allow registration and discovery of plugins

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



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

def initialize
  @registry = {}
end

Instance Method Details

#allObject



21
22
23
# File 'lib/lint_trap/registry.rb', line 21

def all
  registry.values
end

#default(thing_class) ⇒ Object



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

def default(thing_class)
  @registry.default = thing_class.new
end

#find(name) ⇒ Object



17
18
19
# File 'lib/lint_trap/registry.rb', line 17

def find(name)
  registry[name]
end

#register(thing_class) ⇒ Object



12
13
14
15
# File 'lib/lint_trap/registry.rb', line 12

def register(thing_class)
  thing = thing_class.new
  registry[thing.name] = thing
end