Sha256: 72b7853084e21c83b8d2d9f35ed86163e734b342c887dcb4a56642aa2f4196c6

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

module Exlibris
  module Primo
    module WebService
      module Request
        module Client
          def self.included(klass)
            klass.class_eval do
              extend ClassAttributes
            end
          end

          module ClassAttributes
            def client
              @client ||= (has_client?) ? name.demodulize.underscore.to_sym :
                (self.superclass.respond_to? :client) ?
                  self.superclass.client : nil
            end

            # Returns whether this class has a client symbol
            def has_client?
              @has_client ||= false
            end
            protected :has_client?

            # Tell the class it hold the client symbol
            def has_client
              @has_client = true
            end
            protected :has_client
          end

          def client
            @client ||= client_klass.new :base_url => base_url
          end
          protected :client

          def client_klass
            "Exlibris::Primo::WebService::Client::#{self.class.client.to_s.camelize}".constantize
          end
          private :client_klass
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
exlibris-primo-2.1.1 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-2.1.0 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-2.0.0 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.9 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.8 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.7 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.6 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.5 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.4 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.3 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.2 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.1 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.1.0 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.11 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.10 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.9 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.8 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.7 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.6 lib/exlibris/primo/web_service/request/base/client.rb
exlibris-primo-1.0.5 lib/exlibris/primo/web_service/request/base/client.rb