Sha256: c7535c1b60f838fc1e01b7970c7354058d4e23953b411a000cb42bb11571f33e

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

=begin rdoc
  Monitor class
  
  TODO: Fill this out
=end
module PoolParty
  module Monitors    
    
    module ClassMethods
    end
    
    module InstanceMethods
      def expand_when(*arr)
        @expand_when ||= ((arr && arr.empty?) ? options[:expand_when] : configure(:expand_when => self.class.send(:rules,:expand_when,arr,false)))
      end
      
      def contract_when(*arr)
        @contract_when ||= ((arr&&arr.empty?) ? options[:contract_when] : configure(:contract_when => self.class.send(:rules,:contract_when,arr,false)))
      end
    end
    
    def self.register_monitor(*args)
      args.each do |arg|
        (available_monitors << "#{arg}".downcase.to_sym unless available_monitors.include?("#{arg}".downcase.to_sym))
        
        InstanceMethods.module_eval "def #{arg}; @#{arg} ||= messenger_send!(\"get_current_load #{arg}\").to_f rescue -1.0; end"
      end
    end

    def self.available_monitors
      $available_monitors ||= []
    end
    
    class BaseMonitor
      def self.run
        new.run
      end
    end
    
    def self.included(receiver)
      receiver.extend                 PoolParty::Monitors::ClassMethods      
      receiver.send :include,         PoolParty::Monitors::InstanceMethods
      receiver.send :include,         Aska
    end
    
  end
end

Dir["#{File.dirname(__FILE__)}/monitors/*.rb"].each {|f| require f}

module PoolParty
  module Cloud
    class Cloud
      include PoolParty::Monitors
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
auser-poolparty-0.2.53 lib/poolparty/monitors/base_monitor.rb
auser-poolparty-0.2.54 lib/poolparty/monitors/base_monitor.rb
auser-poolparty-0.2.55 lib/poolparty/monitors/base_monitor.rb
auser-poolparty-0.2.56 lib/poolparty/monitors/base_monitor.rb
auser-poolparty-0.2.57 lib/poolparty/monitors/base_monitor.rb
auser-poolparty-0.2.58 lib/poolparty/monitors/base_monitor.rb