Class: Bixby::Model::Base

Inherits:
Object show all
Defined in:
lib/bixby-client/model/base.rb

Direct Known Subclasses

Agent, Check, Command, Host, Metric

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Base

self



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/bixby-client/model/base.rb', line 113

def initialize(hash=nil)
  return if hash.nil?

  hash.each do |k,v|
    instance_variable_set("@#{k}", v)
    next if self.respond_to?(k.to_sym)
    code = <<-EOF
    def #{k}()
      @#{k}
    end
    EOF
    eval(code)
  end
end

Class Method Details

.destroy(id) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/bixby-client/model/base.rb', line 25

def destroy(id)
  raise NotImplementedError
end

.find(id) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/bixby-client/model/base.rb', line 17

def find(id)
  raise NotImplementedError
end

.list(*args) ⇒ Object

Public API methods

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/bixby-client/model/base.rb', line 13

def list(*args)
  raise NotImplementedError
end

.update(id, data) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/bixby-client/model/base.rb', line 21

def update(id, data)
  raise NotImplementedError
end

Instance Method Details

#[](key) ⇒ Object



128
129
130
131
132
133
# File 'lib/bixby-client/model/base.rb', line 128

def [](key)
  if self.respond_to?(key.to_sym) then
    return self.send(key.to_sym)
  end
  return nil
end