Module: Hcloud::EntryLoader

Extended by:
ActiveSupport::Concern
Included in:
Action, Datacenter, FloatingIP, Image, Iso, Location, Pagination, SSHKey, Server, ServerType
Defined in:
lib/hcloud/entry_loader.rb

Instance Method Summary collapse

Instance Method Details

#initialize(resource, parent, client) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hcloud/entry_loader.rb', line 13

def initialize(resource, parent, client)
  @parent = parent
  @client = client
  self.class.const_get(:Attributes).each do |attribute, value|
    case value
    when nil
      self.send("#{attribute}=", resource[attribute.to_s])
    when :time
      unless resource[attribute.to_s].nil?
        self.send("#{attribute}=", Time.parse(resource[attribute.to_s]))
      end
    else 
      if value.is_a?(Class) and value.include?(EntryLoader)
        self.send("#{attribute}=", value.new(resource[attribute.to_s], self, client))
      end
    end
  end
end

#request(*args) ⇒ Object



32
33
34
# File 'lib/hcloud/entry_loader.rb', line 32

def request(*args)
  client.request(*args)
end