lib/wpb/user.rb in wpb-0.0.6.pre vs lib/wpb/user.rb in wpb-0.0.6
- old
+ new
@@ -6,55 +6,28 @@
# == Examples:
# User.find(1).name
# The above will find the user with id of 1 and retrieve their display name
class User < ActiveRecord::Base
+
+ class << self
+ def inspect
+ "User(id: integer, name: string, username: string, email: string)"
+ end
+ end
+
set_table_name :wp_users
set_primary_key :ID
has_many :settings
has_many :pages, :foreign_key => :post_author
has_many :posts, :foreign_key => :post_author
has_many :comments, :foreign_key => :user_id
- ##
- # Grab the name of the selected user
+ alias_attribute :name, :display_name
+ alias_attribute :username, :user_login
+ alias_attribute :email, :user_email
- def name
- display_name
- end
-
- ##
- # Set the name of the selected user
-
- def name= name
- self.display_name = name
- end
-
- ##
- # Grab the username of the selected user
-
- def username
- user_login
- end
-
- ##
- # Set the username of the selected user
-
- def username= username
- self.user_login = username
- end
-
- ##
- # Grab the email of the selected user
-
- def email
- user_email
- end
-
- ##
- # Set the email of the selected user
-
- def email= email
- self.user_email = email
- end
+ def inspect
+ "#<User id: #{id}, name: \"#{name}\", username: \"#{username}\", email: \"#{email}\">"
+ end
end
\ No newline at end of file