Sha256: 1adf442f7b7e86fa985f9d23b0833a74332e2f5261f677adefe06785d159fb5a
Contents?: true
Size: 1.28 KB
Versions: 12
Compression:
Stored size: 1.28 KB
Contents
module Rubix class Application < Model # # == Properties & Finding == # def initialize properties={} super(properties) self.host_id = properties[:host_id] self.host = properties[:host] end zabbix_attr :name, :required => true # # == Associations == # include Associations::BelongsToHost # # == Requests == # def create_params {:name => name, :hostid => host_id} end def update_params { id_field => id, :name => name, :hosts => {:hostid => host_id}} end def self.find_params options={} super().merge({ :hostids => [options[:host_id]], :filter => { :name => options[:name], id_field => options[:id] } }) end def self.build app params = { :id => app[id_field].to_i, :name => app['name'] } # use the host id if available, else use the template id if app['hosts'] && app['hosts'].first && app['hosts'].first['hostid'] params[:host_id] = app['hosts'].first['hostid'].to_i else params[:host_id] = app['templateid'] end new(params) end end end
Version data entries
12 entries across 12 versions & 1 rubygems