Sha256: 4d85b96ece870391ccc40dd93c38840df54ca141077065cee0f274a04b917094

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class Right
# Set: All "+ApiKey" cards
#
module ApiKey;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-account/set/right/api_key.rb"; end
include_set Abstract::AccountField

# DURATIONS = "second|minute|hour|day|week|month|year".freeze

def history?
  false
end

view :raw do
  tr :private_data
end

def validate! api_key
  error =
    case
    when !real?             then [:token_not_found, tr(:error_token_not_found)]
    # when expired?           then [:token_expired, tr(:error_token_expired)]
    when content != api_key then [:incorrect_token, tr(:error_incorrect_token)]
    end
  errors.add(*error) if error
  error.nil?
end

# def expired?
#   !permanent? && updated_at <= term.ago
# end
#
# def permanent?
#   term == "permanent"
# end

# def term
#   @term ||=
#     if expiration.present?
#       term_from_string expiration
#     else
#       Card.config.token_expiry
#     end
# end

# def term_from_string string
#   string.strip!
#   return "permanent" if string == "none"
#   re_match = /^(\d+)[\.\s]*(#{DURATIONS})s?$/.match(string)
#   number, unit = re_match.captures if re_match
#   raise Card::Open::Error, tr(:exception_bad_expiration, example: '2 days') unless unit
#   number.to_i.send unit
# end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card-mod-account/set/right/api_key.rb ~~

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
card-1.101.5 tmpsets/set/mod011-card-mod-account/right/api_key.rb
card-1.101.4 tmpsets/set/mod011-card-mod-account/right/api_key.rb
card-1.101.3 tmpsets/set/mod011-card-mod-account/right/api_key.rb
card-1.101.2 tmpsets/set/mod011-card-mod-account/right/api_key.rb
card-1.101.1 tmpsets/set/mod011-card-mod-account/right/api_key.rb
card-1.101.0 tmpsets/set/mod011-card-mod-account/right/api_key.rb