Sha256: 916100503f83fc20626694816074f111ba0796ea0ba2b13abe4ffec0d534e582
Contents?: true
Size: 586 Bytes
Versions: 17
Compression:
Stored size: 586 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(/\/(.?)/) { "::#{Regexp.last_match[1].upcase}" }.gsub(/(?:^|_)(.)/) { Regexp.last_match[1].upcase } klass.const_get(const_name.to_sym).new(attrs) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems