Class: Motel::Sources::Default
- Inherits:
-
Object
- Object
- Motel::Sources::Default
- Defined in:
- lib/motel/sources/default.rb
Instance Attribute Summary collapse
-
#tenants ⇒ Object
Returns the value of attribute tenants.
Instance Method Summary collapse
- #add_tenant(name, spec) ⇒ Object
- #delete_tenant(name) ⇒ Object
-
#initialize(config = {}) ⇒ Default
constructor
A new instance of Default.
- #tenant(name) ⇒ Object
- #tenant?(name) ⇒ Boolean
- #update_tenant(name, spec) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Default
Returns a new instance of Default.
12 13 14 |
# File 'lib/motel/sources/default.rb', line 12 def initialize(config = {}) @tenants = config[:configurations] || {} end |
Instance Attribute Details
#tenants ⇒ Object
Returns the value of attribute tenants.
8 9 10 |
# File 'lib/motel/sources/default.rb', line 8 def tenants @tenants end |
Instance Method Details
#add_tenant(name, spec) ⇒ Object
24 25 26 27 28 |
# File 'lib/motel/sources/default.rb', line 24 def add_tenant(name, spec) raise ExistingTenantError if tenant?(name) tenants[name] = keys_to_string(spec) end |
#delete_tenant(name) ⇒ Object
37 38 39 |
# File 'lib/motel/sources/default.rb', line 37 def delete_tenant(name) tenants.delete(name) end |
#tenant(name) ⇒ Object
16 17 18 |
# File 'lib/motel/sources/default.rb', line 16 def tenant(name) tenants[name] end |
#tenant?(name) ⇒ Boolean
20 21 22 |
# File 'lib/motel/sources/default.rb', line 20 def tenant?(name) tenants.key?(name) end |
#update_tenant(name, spec) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/motel/sources/default.rb', line 30 def update_tenant(name, spec) raise NonexistentTenantError unless tenant?(name) spec = keys_to_string(spec) tenants[name].merge!(spec) end |