Sha256: 7342d0600c517cf7c629ce33eab55048fac3b8665e30b0fb9d6a97436047395d

Contents?: true

Size: 519 Bytes

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
twitter-7.0.0 lib/twitter/factory.rb
twitter-6.2.0 lib/twitter/factory.rb
twitter-6.1.0 lib/twitter/factory.rb
twitter-6.0.0 lib/twitter/factory.rb
twitter-5.17.0 lib/twitter/factory.rb
twitter-5.16.0 lib/twitter/factory.rb
twitter-5.15.0 lib/twitter/factory.rb