Class: Zm::Client::MountpointJsnsInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb

Overview

class for initialize account mountpoint

Class Method Summary collapse

Class Method Details

.arrow_name(name) ⇒ Object



25
26
27
28
29
# File 'lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb', line 25

def arrow_name(name)
  return name if name.to_s.start_with?('@')

  "@#{name}"
end

.create(parent, json) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb', line 8

def create(parent, json)
  item = MountPoint.new(parent)

  item.instance_variable_set(:@id, json[:id])
  item.instance_variable_set(:@name, json[:name])

  update(item, json)
end

.update(item, json) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/zm/client/mountpoint/mountpoint_jsns_initializer.rb', line 17

def update(item, json)
  item.all_instance_variable_keys.reject { |key| json[key].nil? }.each do |key|
    item.instance_variable_set(arrow_name(key), json[key])
  end

  item
end