Class: RollCall::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/roll_call/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, node_timeout, settings, url) ⇒ Node

Returns a new instance of Node.



8
9
10
11
12
13
# File 'lib/roll_call/node.rb', line 8

def initialize(name,node_timeout,settings,url)
  @name = name
  @node_timeout = node_timeout
  @settings = settings
  @url = url    
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def name
  @name
end

#node_timeoutObject

Returns the value of attribute node_timeout.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def node_timeout
  @node_timeout
end

#settingsObject

Returns the value of attribute settings.



6
7
8
# File 'lib/roll_call/node.rb', line 6

def settings
  @settings
end

Instance Method Details

#registerObject



15
16
17
18
# File 'lib/roll_call/node.rb', line 15

def register
  payload = {service:{"name" => @name, "node_timeout" => @node_timeout, "settings" => @settings}}
  RestClient.post(@url,payload,accept: 'applciation/json')
end

#unregisterObject



20
21
22
# File 'lib/roll_call/node.rb', line 20

def unregister
  RestClient.delete(@url + @name)
end

#update(attributeIn) ⇒ Object



24
25
26
27
28
# File 'lib/roll_call/node.rb', line 24

def update(attributeIn)
  attribute = attributeIn
  payload = {service:attribute}
  RestClient.put(@url + @name,payload,accept: 'applciation/json')
end