app/models/hubstats/label.rb in hubstats-0.0.19 vs app/models/hubstats/label.rb in hubstats-0.0.20

- old
+ new

@@ -15,7 +15,15 @@ attr_accessible :url, :name, :color has_and_belongs_to_many :pull_requests, :join_table => 'hubstats_labels_pull_requests' + def self.first_or_create(label) + if exists = Hubstats::Label.where(name: label[:name]).first + return exists + else + Hubstats::Label.new(name: label[:name], url: label[:url], color: label[:color]) + end + end + end end