Class: Synapse::Easy::Section::Base

Inherits:
Object
  • Object
show all
Includes:
Fake::Hash
Defined in:
lib/synapse/easy/section/base.rb

Direct Known Subclasses

Stats, Tcp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/synapse/easy/section/base.rb', line 11

def initialize params={}
  @address   = params[:address]
  @address ||= "localhost"
  @port      = params[:port]
  @port    ||= Freeport.port
  @name      = params[:name]
  @type      = params[:type]
  @type    ||= "frontend"
  @type      = params[:mode]
  @type    ||= :http
  @options   = params[:options]
  @options ||= []
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def address
  @address
end

#modeObject

Returns the value of attribute mode.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def mode
  @mode
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def name
  @name
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def options
  @options
end

#portObject

Returns the value of attribute port.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def port
  @port
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/synapse/easy/section/base.rb', line 10

def type
  @type
end

Instance Method Details

#bindObject



33
34
35
# File 'lib/synapse/easy/section/base.rb', line 33

def bind
  [address,port].compact.join(":")
end

#each(*args, &block) ⇒ Object



30
31
32
# File 'lib/synapse/easy/section/base.rb', line 30

def each *args, &block
  section_options.each(*args,&block)
end

#labelObject



24
25
26
# File 'lib/synapse/easy/section/base.rb', line 24

def label
  "#{type} #{name}"
end

#section_optionsObject



27
28
29
# File 'lib/synapse/easy/section/base.rb', line 27

def section_options
  options
end

#to_synapseObject



36
37
38
39
40
# File 'lib/synapse/easy/section/base.rb', line 36

def to_synapse
  {
    label => section_options
  }
end