Sha256: 7fb13e0bf1498a8a5fe779d2964af3767c1a3ac4358380d613ea5037507c3f50

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

# module Dailycred
#   class User
#     include ActiveModel::Validations
#     include ActiveModel::Serialization

#     validates_presence_of :email, :pass

#     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 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

#       return false if !self.valid?
#       true
#     end

#     def to_hash
#       {
#         :email => self.email,
#         :pass => self.pass
#       }
#     end

#     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

#   end

# end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dailycred-0.3.1 lib/dailycred/user.rb
dailycred-0.3.0 lib/dailycred/user.rb
dailycred-0.2.0 lib/dailycred/user.rb
dailycred-0.1.8 lib/dailycred/user.rb
dailycred-0.1.7 lib/dailycred/user.rb
dailycred-0.1.6 lib/dailycred/user.rb
dailycred-0.1.5 lib/dailycred/user.rb
dailycred-0.1.461 lib/dailycred/user.rb
dailycred-0.1.46 lib/dailycred/user.rb