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



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

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)


23
24
25
# File 'lib/bixby-client/model/base.rb', line 23

def destroy(id)
  raise NotImplementedError
end

.find(id) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/bixby-client/model/base.rb', line 15

def find(id)
  raise NotImplementedError
end

.list(*args) ⇒ Object

Public API methods

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/bixby-client/model/base.rb', line 11

def list(*args)
  raise NotImplementedError
end

.update(id, data) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/bixby-client/model/base.rb', line 19

def update(id, data)
  raise NotImplementedError
end

Instance Method Details

#[](key) ⇒ Object



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

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