Sha256: ee1a5d14f8d6a1ac38f6fc5ad30b5c5a0602bd99c47f5a84fca306f7ff11b4cf

Contents?: true

Size: 519 Bytes

Versions: 4

Compression:

Stored size: 519 Bytes

Contents

module Twitter
  class Factory
    class << self
      # Construct a new object
      #
      # @param method [Symbol]
      # @param klass [Class]
      # @param attrs [Hash]
      # @raise [IndexError] Error raised when supplied argument is missing a key.
      # @return [Twitter::Base]
      def new(method, klass, attrs = {})
        type = attrs.fetch(method.to_sym)
        const_name = type.split("_").collect(&:capitalize).join
        klass.const_get(const_name.to_sym).new(attrs)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter-8.1.0 lib/twitter/factory.rb
twitter-8.0.1 lib/twitter/factory.rb
twitter-8.0.0 lib/twitter/factory.rb
twitter-8.0.0.rc.1 lib/twitter/factory.rb