Class: Gemstash::DB::CachedRubygem

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

Overview

Sequel model for cached_rubygems table.

Class Method Summary collapse

Class Method Details

.store(upstream, gem_name, resource_type) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/gemstash/db/cached_rubygem.rb', line 7

def self.store(upstream, gem_name, resource_type)
  db.transaction do
    upstream_id = Gemstash::DB::Upstream.find_or_insert(upstream)
    record = self[upstream_id: upstream_id, name: gem_name.name, resource_type: resource_type.to_s]
    return record.id if record
    new(upstream_id: upstream_id, name: gem_name.name, resource_type: resource_type.to_s).tap(&:save).id
  end
end