Sha256: e58a546717edd9e146c56cc7f994697f9545fe351d9cf15f3cb60e41208a2c00

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

require_rel '../helpers/camel_case'

module Hubspot
  module Discovery
    module BaseModuleClient
      module ClassMethods
        def base_module
          modules = name.split('::')
          modules.pop
          modules.join('::')
        end
  
        def api_modules
          []
        end
  
        def api_classes
          []
        end
  
        def define_methods
          define_modules_methods
          define_classes_methods
        end
  
        def define_modules_methods
          api_modules.each do |api_module|
            define_method(api_module) do 
              Kernel.const_get("#{self.class.base_module}::#{Hubspot::Helpers::CamelCase.new.format(__method__.to_s)}::Client").new(params)
            end
          end
        end
        
        def define_classes_methods
          api_classes.each do |api_class|
            define_method("#{api_class}_api") do
              Kernel.const_get("#{self.class.base_module}::#{Hubspot::Helpers::CamelCase.new.format(__method__.to_s)}").new(params)
            end
          end
        end
      end

      attr_reader :params

      def initialize(params)
        @params = params
      end

      def self.included(base)
        base.extend(ClassMethods)
        base.class_eval { define_methods }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hubspot-api-client-14.5.2 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.5.1 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.5.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.4.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.3.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.2.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.1.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-14.0.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-13.2.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-13.1.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-13.0.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-12.0.0 lib/hubspot/discovery/base_module_client.rb
hubspot-api-client-11.2.0 lib/hubspot/discovery/base_module_client.rb