require 'activesupport' require 'net/https' require 'lvs/json_service/request' module LVS module JsonService class Base include ::LVS::JsonService::Request attr_accessor :fields protected class << self @site = "" @services = [] @service_prefix = "" @field_prefix = "" @encrypted = false @ignore_missing = false @auth_cert = "" @auth_key = "" @auth_key_pass = "" @eventmachine_async = false def encrypted=(value) @encrypted = value end def auth_cert=(value) @auth_cert = value end def auth_key=(value) @auth_key = value end def auth_key_pass=(value) @auth_key_pass = value end def agp_location=(value) @agp_location = value end def add_service(service) @services ||= [] @services = @services << service end def service_prefix=(value) @service_prefix = value end def field_prefix=(value) @field_prefix = value end def is_eventmachine_async! @eventmachine_async = true end def site=(value) # value is containing AGP_LOCATION already sometimes: value.gsub!(/^#{AGP_LOCATION}/, '') if defined?(AGP_LOCATION) && value.match(/#{AGP_LOCATION}/) agp = @agp_location ? @agp_location : AGP_LOCATION agp.gsub!(/\/$/, '') value.gsub!(/^\//, '') @site = (agp + '/' + value) end def ignore_missing=(value) @ignore_missing = value end def ignore_missing @ignore_missing end def debug(message) LVS::JsonService::Logger.debug " \033[1;4;32mLVS::JsonService\033[0m #{message}" end def require_ssl? (Module.const_defined?(:SSL_ENABLED) && SSL_ENABLED) || (Module.const_defined?(:SSL_DISABLED) && !SSL_DISABLED) end def define_service(name, service, options = {}, &block) service_name = name service_path = service.split('.') if service_path.size <= 2 internal_service = service prefix = @service_prefix else internal_service = service_path[-2..-1].join('.') prefix = service_path[0..-3].join('.') + '.' end options[:encrypted] = @encrypted if @encrypted options[:eventmachine_async] = @eventmachine_async if @eventmachine_async options[:auth_cert] = @auth_cert if @auth_cert options[:auth_key] = @auth_key if @auth_key options[:auth_key_pass] = @auth_key_pass if @auth_key_pass (class<