Class: Motel::Sources::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/motel/sources/default.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tenantsObject

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

Returns:

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