Sha256: 22788825639836e0c76cfb3412526eb4d25fe612d0cb2dc268da2add8e39d7af

Contents?: true

Size: 604 Bytes

Versions: 15

Compression:

Stored size: 604 Bytes

Contents

# frozen_string_literal: true

module Crunchbase
  # Utilities
  module Utilities
    # API Request
    module CbModel
      attr_accessor :entity_type

      module_function

      def cbobject
        kclass_name.new
      end

      def kclass_name
        @kclass_name ||= exact_kclass_object
      end

      def exact_kclass_object
        return entity_type if entity_type.is_a?(Class)

        cb_type = [
          'Crunchbase',
          'Models',
          entity_type.split('_').map(&:capitalize).join
        ].join('::')
        Kernel.const_get("::#{cb_type}")
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
crunchbase4-0.2.6 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.2.5 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.2.4 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.2.2 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.2.1 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.2.0 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.9 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.8 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.7 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.6 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.5 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.4 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.3 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.2 lib/crunchbase/utilities/cb_model.rb
crunchbase4-0.1.1 lib/crunchbase/utilities/cb_model.rb