Class: Coder
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Coder
- Defined in:
- app/models/coder.rb
Instance Method Summary (collapse)
-
- (Object) find_or_create(name)
given a coder name, find and return it or goto github and grab the user details and return a new coder.
-
- (Object) get_details(name)
given a coder name, goto github and grab the user details and create a new coder.
Instance Method Details
- (Object) find_or_create(name)
given a coder name, find and return it or goto github and grab the user details and return a new coder
32 33 34 35 |
# File 'app/models/coder.rb', line 32 def find_or_create(name) coder = Coder.where(:login => name).first !coder.blank? ? coder : self.get_details(name) end |
- (Object) get_details(name)
given a coder name, goto github and grab the user details and create a new coder
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/coder.rb', line 14 def get_details(name) begin coder = Octokit.user(name) rescue return false, "We had a problem finding that user" else col = Coder.columns.map(&:name) coder.delete_if { |key| !col.include?(key)} return Coder.create!(coder) end end |