summaryrefslogtreecommitdiff
path: root/example/models/user.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-06-26 18:56:43 +0200
committerAzul <azul@leap.se>2012-06-26 18:56:43 +0200
commit12b30b7e861c510593c6a8bd4bae68c2126106db (patch)
tree4c578c34958f020dd0cddc3df3ac1e0f87b776d6 /example/models/user.rb
parentf32497f143ef95264706dba27ce3e7a26d7ba6a4 (diff)
moved user and log class to models, verify prints logs
Diffstat (limited to 'example/models/user.rb')
-rw-r--r--example/models/user.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/example/models/user.rb b/example/models/user.rb
new file mode 100644
index 0000000..f3f86ba
--- /dev/null
+++ b/example/models/user.rb
@@ -0,0 +1,25 @@
+class User
+
+ def self.current
+ # p "getting #{@current ? @current.login : 'nil'}"
+ @current ||= User.new
+ end
+
+ attr_accessor :login
+ attr_accessor :password
+ attr_accessor :active
+
+ def signup!(params)
+ self.login = params.delete('login')
+ self.password = params.delete('password')
+ self.active = false
+ end
+
+ def login!(params)
+ self.active = valid_login?(params[:login], params[:password])
+ end
+
+ def valid_login?(login, password)
+ (self.login == login) and (self.password == password)
+ end
+end