Sha256: 661f9224a3223a1b3467504b2ae3c42d044d291083ca7dd822df79e9cff94d20
Contents?: true
Size: 546 Bytes
Versions: 4
Compression:
Stored size: 546 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.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase} 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-5.1.1 | lib/twitter/factory.rb |
twitter-5.1.0 | lib/twitter/factory.rb |
twitter-5.0.1 | lib/twitter/factory.rb |
twitter-5.0.0 | lib/twitter/factory.rb |