Class: Google::SafeBrowsingRedirectUrl

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/rails/generators/google/model/templates/google/safe_browsing_redirect_url.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.url_hash_key(url_str) ⇒ Object



30
31
32
# File 'lib/rails/generators/google/model/templates/google/safe_browsing_redirect_url.rb', line 30

def url_hash_key url_str
  Digest::MD5.hexdigest(url_str)
end

Instance Method Details

#set_download_attrObject



22
23
24
25
26
27
# File 'lib/rails/generators/google/model/templates/google/safe_browsing_redirect_url.rb', line 22

def set_download_attr
  if !self.download_state.blank? && self.download_state != COMPLETED
    self.download_attempts ||= 0
    self.download_attempts += 1
  end
end

#set_other_attrsObject



15
16
17
18
19
20
# File 'lib/rails/generators/google/model/templates/google/safe_browsing_redirect_url.rb', line 15

def set_other_attrs
  ord = Google::SafeBrowsingRedirectUrl.maximum(:order)
  self.order = ord.nil?? 1 : ord + 1
  self.url_hash = SafeBrowsingRedirectUrl.url_hash_key(self.url)
  set_download_attr
end