class Miteru::Record
Public Class Methods
create_by_kit_and_hash(kit, hash)
click to toggle source
Create a new record based on a kit
@param [Miteru::Kit] kit @param [String] hash
@return [Miteru::Record]
# File lib/miteru/record.rb, line 30 def create_by_kit_and_hash(kit, hash) record = new( hash: hash, source: kit.source, hostname: kit.hostname, url: kit.decoded_url, headers: kit.headers, filename: kit.filename, filesize: kit.filesize, mime_type: kit.mime_type, downloaded_as: kit.filepath_to_download ) record.save record rescue TypeError, ActiveRecord::RecordNotUnique => _e nil end
unique_hash?(hash)
click to toggle source
Check uniqueness of a record by a hash
@param [String] hash
@return [Boolean] true if it is unique. Otherwise false.
# File lib/miteru/record.rb, line 15 def unique_hash?(hash) record = find_by(hash: hash) return true if record.nil? false end