Added v 0.2.3 snapshot.
[twitter4r-core.git] / examples / model.rb
blob8818b235cdf900e257f3afb52df23edad550a005
1 # = Model API Examples
2 #  require('rubygems')
3 #  gem('twitter4r', '0.2.0')
4 #  require('twitter')
5
6 # The following is only required if you want to use some configuration 
7 # helper methods like <tt>Twitte4R::Client.from_config</tt> for 
8 # sensitive/instance context.
9 #  require 'twitter/console'
10 #  config_file = File.join(File.dirname(__FILE__), '..', 'config', 'twitter.yml')
11
12 # To override client connection configuration please refer to 
13 # the {<tt>configure.rb</tt>}[file:configure_rb.html] example code.
14 #  twitter = Twitter::Client.from_config(config_file)
15
16 # The purpose of the <b>Model API</b> is to make Twitter REST methods 
17 # integrated into class and instance methods that resemble 
18 # <tt>ActiveRecord</tt> class API.
19
20 # == Create Methods
21 # For example, suppose we want to create a new direct message to a friend:
22 #  message = Twitter::Message.create(
23 #    :text => 'Ich liebe dich!',
24 #    :client => twitter,
25 #    :recipient => 'myspouse')
26
27 # We can also create a new status message, which updates our (the 
28 # authenticated user's) timeline:
29 #  status = Twitter::Status.create(
30 #    :text => 'Doing early Christmas shopping in July',
31 #    :client => twitter)
32
33 # Notice we must always pass in a <tt>:client</tt> key-value pair giving
34 # the client context object.
35
36 # There is currently no useful Twitter::User.create implementation as 
37 # <tt>Twitter</tt> does not provide this server REST API.  This is *not* 
38 # a <tt>Twitter4R</tt> limitation.  Please harass the Twitter.com/Obvious 
39 # developer for this not me please.
40
41 # == Finder Methods
42 # We can also use finder methods that look very similar to 
43 # <tt>ActiveRecord</tt> style classes:
44 #  user = Twitter::User.find('myfriend', twitter)
45 #  status = Twitter::Status.find(status.id, twitter)
46
47 # There is currently no useful Twitter::Message.find implementation as 
48 # <tt>Twitter</tt> does not provide this server REST API.  Ths is *not* 
49 # a <tt>Twitter4R</tt> limitation.  Please harass the Twitter.com/Obvious 
50 # developer for this not me please.
51
52 # == Domain Specific Methods
53 # <tt>Twitter::User</tt> has a few domain specific methods for convenience:
54 #  user.is_me? # => false since <tt>user</tt> is 'myfriend' not authenticated user
55 #  me = Twitter::User.find('mylogin')
56 #  me.is_me? # => true since <tt>me</tt> is authenticated user
57 #  me.followers # => return Array of followers for authenticated user (only available for authenticated user)
58 #  me.friends # => returns Array of friends for that user instance
59 #  me.befriend(user) # => user (only available for authenticated user)
60 #  me.defriend(user) # => user (only available for authenticated user)