Class: Tinypass::TokenData
- Inherits:
-
Object
- Object
- Tinypass::TokenData
- Defined in:
- lib/tinypass/token/token_data.rb
Constant Summary collapse
- MARK_YEAR_MILLIS =
1293858000000- METER_REMINDER =
10- METER_STRICT =
20- METER_TRIAL_ENDTIME =
'mtet'- METER_TRIAL_ACCESS_PERIOD =
'mtap'- METER_LOCKOUT_ENDTIME =
'mlet'- METER_LOCKOUT_PERIOD =
'mlp'- METER_TRIAL_MAX_ACCESS_ATTEMPTS =
'mtma'- METER_TRIAL_ACCESS_ATTEMPTS =
'mtaa'- METER_TYPE =
'mt'- ACCESS_ID =
'id'- RID =
'rid'- UID =
'uid'- EX =
'ex'- EARLY_EX =
'eex'- IPS =
'ips'
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #fetch(*args) ⇒ Object
-
#initialize(data = {}) ⇒ TokenData
constructor
A new instance of TokenData.
- #merge(hash) ⇒ Object (also: #add_fields)
- #rid ⇒ Object
- #size ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ TokenData
Returns a new instance of TokenData.
26 27 28 |
# File 'lib/tinypass/token/token_data.rb', line 26 def initialize(data = {}) @data = data end |
Class Method Details
.convert_to_epoch_seconds(seconds_from_now) ⇒ Object
67 68 69 70 |
# File 'lib/tinypass/token/token_data.rb', line 67 def self.convert_to_epoch_seconds(seconds_from_now) seconds_from_now /= 1000 if seconds_from_now > MARK_YEAR_MILLIS seconds_from_now end |
Instance Method Details
#[](key) ⇒ Object
34 35 36 37 |
# File 'lib/tinypass/token/token_data.rb', line 34 def [](key) key = key.to_s @data[key] end |
#[]=(key, value) ⇒ Object
39 40 41 42 |
# File 'lib/tinypass/token/token_data.rb', line 39 def []=(key, value) key = key.to_s @data[key] = value end |
#fetch(*args) ⇒ Object
48 49 50 51 |
# File 'lib/tinypass/token/token_data.rb', line 48 def fetch(*args) args[0] = args[0].to_s @data.fetch(*args) end |
#merge(hash) ⇒ Object Also known as: add_fields
53 54 55 56 57 58 59 60 |
# File 'lib/tinypass/token/token_data.rb', line 53 def merge(hash) stringified_hash = {} hash.keys.each do |key| stringified_hash[key.to_s] = hash[key] end @data.merge!(stringified_hash) end |
#rid ⇒ Object
30 31 32 |
# File 'lib/tinypass/token/token_data.rb', line 30 def rid @data[RID] end |
#size ⇒ Object
63 64 65 |
# File 'lib/tinypass/token/token_data.rb', line 63 def size @data.size end |
#values ⇒ Object
44 45 46 |
# File 'lib/tinypass/token/token_data.rb', line 44 def values @data end |