Class: DynamicLinks::ShortenedUrl
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- DynamicLinks::ShortenedUrl
- Defined in:
- app/models/dynamic_links/shortened_url.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_or_create!(client, short_url, url) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/dynamic_links/shortened_url.rb', line 26 def self.find_or_create!(client, short_url, url) transaction do record = find_or_create_by!(client: client, short_url: short_url) do |record| record.url = url end record end rescue ActiveRecord::RecordInvalid => e # Log the error and re-raise if needed or return a meaningful error message DynamicLinks::Logger.log_error("ShortenedUrl creation failed: #{e.}") raise e end |
Instance Method Details
#expired? ⇒ Boolean
39 40 41 |
# File 'app/models/dynamic_links/shortened_url.rb', line 39 def expired? expires_at&.past? end |