Skip to content

Commit

Permalink
Add update method
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 3, 2012
1 parent 7d42dd5 commit 99efde0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ def self.new(attrs={})
@@identity_map[self.name][Marshal.dump(attrs)] || super(attrs)
end

# Initializes a new Base object
# Initializes a new object
#
# @param attrs [Hash]
# @return [Twitter::Base]
def initialize(attrs={})
@attrs = attrs
self.update(attrs)
@@identity_map[self.class.name][Marshal.dump(attrs)] = self
end

# Initializes a new Base object
# Fetches an attribute of an object using hash notation
#
# @param method [String, Symbol] Message to send to the object
def [](method)
Expand All @@ -46,5 +46,14 @@ def [](method)
nil
end

# Update the attributes of an object
#
# @param attrs [Hash]
# @return [Twitter::Base]
def update(attrs)
@attrs = attrs
self
end

end
end
6 changes: 3 additions & 3 deletions lib/twitter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def friendship(source, target, options={})
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
# @rate_limited No
# @requires_authentication Yes
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :follow (false) Enable notifications for the target user.
# @return [Twitter::User] The followed user.
Expand Down Expand Up @@ -692,7 +692,7 @@ def follow(*args)
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
# @rate_limited No
# @requires_authentication Yes
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :follow (false) Enable notifications for the target user.
# @return [Array<Twitter::User>] The followed users.
Expand Down Expand Up @@ -721,7 +721,7 @@ def follow!(*args)
# @see https://dev.twitter.com/docs/api/1/post/friendships/destroy
# @rate_limited No
# @requires_authentication Yes
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
# @return [Array<Twitter::User>] The unfollowed users.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
Expand Down

0 comments on commit 99efde0

Please sign in to comment.