Class: Odania::Config::BackendGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/odania/config/backend_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, backends = []) ⇒ BackendGroup

Returns a new instance of BackendGroup.



6
7
8
9
10
# File 'lib/odania/config/backend_group.rb', line 6

def initialize(name, backends=[])
	self.name = name
	self.core_backend = false
	self.backends = backends
end

Instance Attribute Details

#backendsObject

Returns the value of attribute backends.



4
5
6
# File 'lib/odania/config/backend_group.rb', line 4

def backends
  @backends
end

#core_backendObject

Returns the value of attribute core_backend.



4
5
6
# File 'lib/odania/config/backend_group.rb', line 4

def core_backend
  @core_backend
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/odania/config/backend_group.rb', line 4

def name
  @name
end

Instance Method Details

#add_backend(backend) ⇒ Object



12
13
14
# File 'lib/odania/config/backend_group.rb', line 12

def add_backend(backend)
	self.backends << backend
end

#check_core_backend(tags) ⇒ Object



16
17
18
# File 'lib/odania/config/backend_group.rb', line 16

def check_core_backend(tags)
	self.core_backend = tags.include?('core-backend')
end

#dumpObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/odania/config/backend_group.rb', line 20

def dump
	backend_data = []
	backends.each do |backend|
		backend_data << backend.dump
	end

	{
		'name' => name,
		'backends' => backend_data
	}
end

#load(data) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/odania/config/backend_group.rb', line 32

def load(data)
	self.name = data['name']

	unless data['backends'].nil?
		data['backends'].each do |backend_data|
			self.backends << Backend.new.load(backend_data)
		end
	end
end