Class: GitContacts::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/gitcontacts/Request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(hash) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitcontacts/Request.rb', line 10

def create hash
  # all keys are required
  if hash.keys == GitContacts::request_keys
    obj = RequestObject.new
    obj.uid = hash[:uid]
    obj.gid = hash[:gid]
    obj.card_id = hash[:card_id]
    obj.action = hash[:action]
    obj.content = hash[:content]
    obj.request_id
  end
end

.delete(request_id) ⇒ Object



23
24
25
# File 'lib/gitcontacts/Request.rb', line 23

def delete request_id
  return true if RequestObject::delete(request_id) > 0
end

.exist?(request_id) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/gitcontacts/Request.rb', line 6

def exist? request_id
  return true if RequestObject::exist?(request_id)
end

Instance Method Details

#allow(operator) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/gitcontacts/Request.rb', line 61

def allow operator
  author = User.new getuid
  contacts = Gitdb::Contacts.new(uid).access getgid
  card = Gitdb::Card.new contacts.repo
  
  case getaction
  when 'create'
    card.create uid 
  when 'setmeta'
    card.access(getcard_id).setmeta getcontent
  when 'setdata'
    card.access(getcard_id).setdata getcontent
  when 'delete'
    card.access(getcard_id).delete
  end
  
  commit_obj = {
    :author => { :name => author.getuid, :email => author.getemail, :time => get_req_time },
    :committer => { :name => operator.getuid, :email => operator.getemail, :time => Time.now }
  }

  contacts.make_a_commit commit_obj
  card.getmeta[:id]
end

#auto_merge?(uid) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/gitcontacts/Request.rb', line 57

def auto_merge? uid
  false
end

#denyObject



86
87
88
89
# File 'lib/gitcontacts/Request.rb', line 86

def deny
  # deny merge here
  GitContacts::Request::delete @obj.request_id
end

#get_req_timeObject



49
50
51
# File 'lib/gitcontacts/Request.rb', line 49

def get_req_time
  @obj.time if @obj
end

#getactionObject



41
42
43
# File 'lib/gitcontacts/Request.rb', line 41

def getaction
  @obj.action if @obj
end

#getcard_idObject



45
46
47
# File 'lib/gitcontacts/Request.rb', line 45

def getcard_id
  @obj.card_id if @obj
end

#getcontentObject



53
54
55
# File 'lib/gitcontacts/Request.rb', line 53

def getcontent
  @obj.content if @obj
end

#getgidObject



37
38
39
# File 'lib/gitcontacts/Request.rb', line 37

def getgid
  @obj.gid if @obj
end

#getuidObject



33
34
35
# File 'lib/gitcontacts/Request.rb', line 33

def getuid
  @obj.uid if @obj
end

#initiazlie(request_id) ⇒ Object



29
30
31
# File 'lib/gitcontacts/Request.rb', line 29

def initiazlie request_id
  @obj =  RequestObject::access request_id
end