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
code review: @AustinChou.
- #deny ⇒ Object
- #get_req_time ⇒ Object
- #getaction ⇒ Object
- #getcard_id ⇒ Object
- #getcontent ⇒ Object
- #getgid ⇒ Object
- #getuid ⇒ Object
-
#initialize(request_id) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(request_id) ⇒ Request
Returns a new instance of Request.
28 29 30 |
# File 'lib/gitcontacts/Request.rb', line 28 def initialize request_id @obj = RequestObject::access request_id end |
Class Method Details
.create(hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gitcontacts/Request.rb', line 10 def create hash # all keys are required obj = RequestObject.new obj.uid = hash[:uid] obj.gid = hash[:gid] obj.time = Time.now.to_i obj.card_id = hash[:card_id] if hash.member? :card_id obj.action = hash[:action] obj.content = hash[:content] if hash.member? :content obj.request_id end |
.delete(request_id) ⇒ Object
22 23 24 |
# File 'lib/gitcontacts/Request.rb', line 22 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
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/gitcontacts/Request.rb', line 70 def allow operator = User.new getuid operator = User.new operator contacts = Gitdb::Contacts.new(getuid).access getgid card = Gitdb::Card.new contacts.repo case getaction when 'create' card.create getuid when 'setmeta' card.access(getcard_id). JSON.parse(getcontent, { symbolize_names: true }) when 'setdata' card.access(getcard_id).setdata JSON.parse(getcontent, { symbolize_names: true }) when 'delete' card.access(getcard_id).delete end commit_obj = { :author => { :name => .getuid, :email => .getemail, :time => Time.at(get_req_time.to_i) }, :committer => { :name => operator.getuid, :email => operator.getemail, :time => Time.now } } contacts.make_a_commit commit_obj card.[:id] end |
#auto_merge?(uid) ⇒ Boolean
code review: @AustinChou
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gitcontacts/Request.rb', line 57 def auto_merge? uid if contacts = Contacts.new(getgid) if contacts.getadmins.include? uid return true else case getaction when "setdata" ,"delete" return true if Gitdb::Card.new(getgid).access(getcard_id).[:owner] == getuid # to-do end end end end |
#deny ⇒ Object
96 97 98 99 100 101 |
# File 'lib/gitcontacts/Request.rb', line 96 def deny # deny merge here = User.new getuid .remove_request @obj.request_id Request::delete @obj.request_id end |
#get_req_time ⇒ Object
48 49 50 |
# File 'lib/gitcontacts/Request.rb', line 48 def get_req_time @obj.time.value if @obj end |
#getaction ⇒ Object
40 41 42 |
# File 'lib/gitcontacts/Request.rb', line 40 def getaction @obj.action.value if @obj end |
#getcard_id ⇒ Object
44 45 46 |
# File 'lib/gitcontacts/Request.rb', line 44 def getcard_id @obj.card_id.value if @obj end |
#getcontent ⇒ Object
52 53 54 |
# File 'lib/gitcontacts/Request.rb', line 52 def getcontent @obj.content.value if @obj end |
#getgid ⇒ Object
36 37 38 |
# File 'lib/gitcontacts/Request.rb', line 36 def getgid @obj.gid.value if @obj end |
#getuid ⇒ Object
32 33 34 |
# File 'lib/gitcontacts/Request.rb', line 32 def getuid @obj.uid.value if @obj end |