Skip to content

Commit

Permalink
Some improvements to the dummy app's User
Browse files Browse the repository at this point in the history
 * add an ID so it quacks more like an AR object
 * add puts and inspect for debugging
  • Loading branch information
James A. Rosen committed Nov 1, 2011
1 parent 442e8ad commit 9fd1ff2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/dummy_app/app/models/user.rb
@@ -1,14 +1,24 @@
class User

attr_reader :name
attr_reader :name, :id

def initialize(options = {})
@name = options[:name]
@admin = options[:admin]
@id = options[:id]
end

def admin?
!!@admin
end

def to_s
name
end

def inspect
type = @admin ? 'Admin' : 'User'
"<Mock #{type} ##{id}: #{name}>"
end

end

0 comments on commit 9fd1ff2

Please sign in to comment.