lib/dailycred/user.rb in dailycred-0.1.45 vs lib/dailycred/user.rb in dailycred-0.1.46

- old
+ new

@@ -1,63 +1,63 @@ -module Dailycred - class User - include ActiveModel::Validations - include ActiveModel::Serialization +# module Dailycred +# class User +# include ActiveModel::Validations +# include ActiveModel::Serialization - validates_presence_of :email, :pass +# validates_presence_of :email, :pass - attr_accessor :client, :email, :pass, :authorized +# attr_accessor :client, :email, :pass, :authorized - def initialize client, user = {} - self.client = client - self.authorized = false - user.each do |k,v| - self[k] = v if self.respond_to(k) - end - end +# def initialize client, user = {} +# self.client = client +# self.authorized = false +# user.each do |k,v| +# self[k] = v if self.respond_to(k) +# end +# end - def login - if !self.valid? - #it didn't work already, return false - return false - end +# def login +# if !self.valid? +# #it didn't work already, return false +# return false +# end - response = JSON.parse client.login(self.to_hash) - err_parser response +# response = JSON.parse client.login(self.to_hash) +# err_parser response - return false if !self.valid? - true - end +# return false if !self.valid? +# true +# end - def to_hash - { - :email => self.email, - :pass => self.pass - } - end +# def to_hash +# { +# :email => self.email, +# :pass => self.pass +# } +# end - private +# private - #response is a hash, which is - #a json-parsed http response body - def err_parser response - if !response["worked"] - self.authorized = false - response["errors"].each do |err| - attrib = err["attribute"] - message = err["message"] - if attrib == "form" - self.errors.add_to_base message - else - if attrib == "user" - self.errors.add :email, message - elsif self.respond_to attrib - self.errors.add attrib, message - end - end - end - end - end +# #response is a hash, which is +# #a json-parsed http response body +# def err_parser response +# if !response["worked"] +# self.authorized = false +# response["errors"].each do |err| +# attrib = err["attribute"] +# message = err["message"] +# if attrib == "form" +# self.errors.add_to_base message +# else +# if attrib == "user" +# self.errors.add :email, message +# elsif self.respond_to attrib +# self.errors.add attrib, message +# end +# end +# end +# end +# end - end +# end -end +# end \ No newline at end of file