Class: Twitter::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter/factory.rb

Direct Known Subclasses

ActionFactory, GeoFactory, MediaFactory

Class Method Summary collapse

Class Method Details

.fetch_or_new(method, klass, attrs = {}) ⇒ Twitter::Action::Favorite, ...

Instantiates a new action object

Parameters:

  • attrs (Hash) (defaults to: {})

Returns:

Raises:

  • (ArgumentError)

    Error raised when supplied argument is missing an :action key.



11
12
13
14
15
16
17
18
# File 'lib/twitter/factory.rb', line 11

def self.fetch_or_new(method, klass, attrs={})
  return unless attrs
  if type = attrs.delete(method.to_sym)
    klass.const_get(type.camelize.to_sym).fetch_or_new(attrs)
  else
    raise ArgumentError, "argument must have :#{method} key"
  end
end