Class: Gemstash::DB::Upstream

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/gemstash/db/upstream.rb

Overview

Sequel model for upstreams table.

Class Method Summary collapse

Class Method Details

.find_or_insert(upstream) ⇒ Object



5
6
7
8
9
# File 'lib/gemstash/db/upstream.rb', line 5

def self.find_or_insert(upstream)
  record = self[uri: upstream.to_s]
  return record.id if record
  new(uri: upstream.to_s, host_id: upstream.host_id).tap(&:save).id
end