require 'activesupport' require 'net/https' require 'lvs/json_service/request' module LVS module JsonService class Base include ::LVS::JsonService::Request @@services = [] @@cache = CACHE if defined?(CACHE) @@service_prefix = "" attr_accessor :fields cattr_accessor :service_prefix cattr_accessor :field_prefix cattr_accessor :cache protected def self.site=(value) # value is containing AGP_LOCATION already sometimes: if SSL_DISABLED value.gsub!(/^#{AGP_LOCATION}/, '') if AGP_LOCATION && value.match(/#{AGP_LOCATION}/) agp = AGP_LOCATION.gsub(/\/$/, '') else value.gsub!(/^#{AGP_LOCATION}/, '') value.gsub!(/^#{SSL_AGP_LOCATION}/, '') if SSL_AGP_LOCATION && value.match(/#{SSL_AGP_LOCATION}/) agp = SSL_AGP_LOCATION.gsub(/\/$/, '') end value.gsub!(/^\//, '') @@site = (agp + '/' + value) end def self.debug(message) Rails.logger.debug " \033[1;4;32mLVS::JsonService\033[0m #{message}" end def self.define_cached_service(name, service, options) (class< err raise err if tried Rails.logger.info("JSON API CALL RETRY: #{err} - #{method} - #{args.to_yaml}") tried = true retry end ensure mutex.unlock if AppTools.is_memcached_threaded? end end end def self.define_service(name, service, options = {}) 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 if options[:cached] service_name = "call_#{name}" self.define_cached_service(name, service, options) end (class<