Class: Miteru::Record
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Miteru::Record
- Defined in:
- lib/miteru/record.rb
Class Method Summary collapse
-
.create_by_kit_and_hash(kit, hash) ⇒ Miteru::Record
Create a new record based on a kit.
-
.unique_hash?(hash) ⇒ Boolean
Check uniqueness of a record by a hash.
Class Method Details
.create_by_kit_and_hash(kit, hash) ⇒ Miteru::Record
Create a new record based on a kit
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/miteru/record.rb', line 30 def create_by_kit_and_hash(kit, hash) record = new( hash: hash, 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) ⇒ Boolean
Check uniqueness of a record by a hash
15 16 17 18 19 20 |
# File 'lib/miteru/record.rb', line 15 def unique_hash?(hash) record = find_by(hash: hash) return true if record.nil? false end |