Class: GitContacts::Request
- Inherits:
-
Object
- Object
- GitContacts::Request
- Defined in:
- lib/gitcontacts/Request.rb
Class Method Summary collapse
Instance Method Summary collapse
- #allow(operator) ⇒ Object
- #auto_merge?(uid) ⇒ Boolean
- #deny ⇒ Object
- #get_req_time ⇒ Object
- #getaction ⇒ Object
- #getcard_id ⇒ Object
- #getcontent ⇒ Object
- #getgid ⇒ Object
- #getuid ⇒ Object
- #initiazlie(request_id) ⇒ Object
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
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 = 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). getcontent when 'setdata' card.access(getcard_id).setdata getcontent when 'delete' card.access(getcard_id).delete end commit_obj = { :author => { :name => .getuid, :email => .getemail, :time => get_req_time }, :committer => { :name => operator.getuid, :email => operator.getemail, :time => Time.now } } contacts.make_a_commit commit_obj card.[:id] end |
#auto_merge?(uid) ⇒ Boolean
57 58 59 |
# File 'lib/gitcontacts/Request.rb', line 57 def auto_merge? uid false end |
#deny ⇒ Object
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_time ⇒ Object
49 50 51 |
# File 'lib/gitcontacts/Request.rb', line 49 def get_req_time @obj.time if @obj end |
#getaction ⇒ Object
41 42 43 |
# File 'lib/gitcontacts/Request.rb', line 41 def getaction @obj.action if @obj end |
#getcard_id ⇒ Object
45 46 47 |
# File 'lib/gitcontacts/Request.rb', line 45 def getcard_id @obj.card_id if @obj end |
#getcontent ⇒ Object
53 54 55 |
# File 'lib/gitcontacts/Request.rb', line 53 def getcontent @obj.content if @obj end |
#getgid ⇒ Object
37 38 39 |
# File 'lib/gitcontacts/Request.rb', line 37 def getgid @obj.gid if @obj end |
#getuid ⇒ Object
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 |