Class: EasyCaddy::Registry
- Inherits:
-
Object
- Object
- EasyCaddy::Registry
- Defined in:
- lib/easy_caddy/registry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(site) ⇒ Object
- #all ⇒ Object
- #find(name) ⇒ Object
-
#initialize(path = Paths.registry) ⇒ Registry
constructor
A new instance of Registry.
- #remove(name) ⇒ Object
- #update(site) ⇒ Object
Constructor Details
Class Method Details
Instance Method Details
#add(site) ⇒ Object
25 26 27 28 |
# File 'lib/easy_caddy/registry.rb', line 25 def add(site) @data[site.name] = site.to_h save end |
#all ⇒ Object
16 17 18 |
# File 'lib/easy_caddy/registry.rb', line 16 def all @data.values.map { |h| Site.from_h(h) } end |
#find(name) ⇒ Object
20 21 22 23 |
# File 'lib/easy_caddy/registry.rb', line 20 def find(name) h = @data[name] Site.from_h(h) if h end |
#remove(name) ⇒ Object
37 38 39 40 |
# File 'lib/easy_caddy/registry.rb', line 37 def remove(name) @data.delete(name) save end |
#update(site) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/easy_caddy/registry.rb', line 30 def update(site) raise ArgumentError, "Unknown site: #{site.name}" unless @data.key?(site.name) @data[site.name] = site.to_h save end |