Sha256: e2be0acf822224453dce32061b420da3ae57683491e2e816d548d9ac9e71e945

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module DcmgrResource
  class Base < ActiveResource::Base

    # self.site = 'http://your.dcmgr.api.server'
    self.timeout = 30
    self.format = :json
    self.prefix = '/api/'
    
    @@debug = false
    
    class << self
      
      def total_resource
        result = self.find(:first,:params => {:start => 0,:limit => 1})
        result.owner_total
      end
      # If headers are not defined in a given subclass, then obtain
      # headers from the superclass.
      
      def set_debug(debug = true)
        @@debug = debug
      end
    end
    
    ActiveResource::Connection.class_eval do 

      private
      
      def default_header
        @default_header = {
          'X-VDC-ACCOUNT-UUID' => self.class.send(:class_variable_get,:@@vdc_account_uuid)
        }
      end
      
      def configure_http(http)
        http = apply_ssl_options(http)

        #add debug 
        http.set_debug_output($stderr) if @@debug

        # Net::HTTP timeouts default to 60 seconds.
        if @timeout
          http.open_timeout = @timeout
          http.read_timeout = @timeout
        end

        http
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wakame-vdc-webui-10.12.0 app/models/dcmgr_resource/base.rb
wakame-vdc-webui-10.11.0 app/models/dcmgr_resource/base.rb