Sha256: c89c041546a2a335bd775590d3efbd7a1aa3a19f57020230792dd01c6885f9c1

Contents?: true

Size: 377 Bytes

Versions: 1

Compression:

Stored size: 377 Bytes

Contents

module Twitter
  class Factory

    def self.new(method, klass, attrs={})
      type = attrs.delete(method.to_sym)
      if type
        const_name = type.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
        klass.const_get(const_name.to_sym).new(attrs)
      else
        raise ArgumentError, "argument must have :#{method} key"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter-5.0.0.rc.1 lib/twitter/factory.rb