Sha256: b647e251edce2881c122e0f4224f92b9c5c439206675b3d9def091d9764dabe2

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'digest/sha1'
require "uri"

require "model/domain_model.rb"
require "models/blurb.rb"

class FriendRequest < DomainModel
  property :id,:string,:is_primary_key=>true
   property :user_name,:string
   property :friend_user_name,:string
   property :message,:clob
   property :answer,:boolean
   property :created_time_utc,:date
 belongs_to :User,:user_name,:user
 belongs_to :User,:friend_user_name,:friend_user
 index :user_name_friend_name_and_answer_is_null,[:user_name,:friend_user_name,IsNullTransform.new(:answer)],:unique=>true
 index :user_name_and_answer_is_null,[:user_name,IsNullTransform.new(:answer)]
 index :friend_name_and_answer_is_null,[:friend_user_name,IsNullTransform.new(:answer)]
  def FriendRequest.request_friendship(from_user_name,to_user_name,message)
    old_request=    find_old_request(from_user_name,to_user_name)
   return false if old_request!=nil
    new_request=FriendRequest.new
    new_request.user_name=from_user_name
    new_request.friend_user_name=to_user_name
    new_request.message=message
    new_request.created_time_utc=Time.now.gmtime
    new_request.save
    return true
  end
  def FriendRequest.find_old_request(from_user_name,to_user_name)
      FriendRequest.find_by_user_name_friend_name_and_answer_is_null(from_user_name,to_user_name,true)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloudwow-not_relational-0.1.0 test/models/friend_request.rb