Module: Hello::RailsActiveRecord::Access
- Extended by:
- ActiveSupport::Concern
- Included in:
- Access
- Defined in:
- lib/hello/rails_active_record/access.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #active_token_or_destroy ⇒ Object
- #as_json_web_api ⇒ Object
- #full_device_name ⇒ Object
-
#keep_alive! ⇒ Object
CUSTOM METHODS.
- #sudo_expire! ⇒ Object
Instance Method Details
#active_token_or_destroy ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/hello/rails_active_record/access.rb', line 29 def active_token_or_destroy if expires_at.future? token else destroy && (return nil) end end |
#as_json_web_api ⇒ Object
37 38 39 |
# File 'lib/hello/rails_active_record/access.rb', line 37 def as_json_web_api as_json.slice(*%w(expires_at token user_id)).merge({ user: user.as_json_web_api }) end |
#full_device_name ⇒ Object
25 26 27 |
# File 'lib/hello/rails_active_record/access.rb', line 25 def full_device_name Hello::Utils::DeviceName.instance.parse(user_agent_string) end |
#keep_alive! ⇒ Object
CUSTOM METHODS
21 22 23 |
# File 'lib/hello/rails_active_record/access.rb', line 21 def keep_alive! renew! if expiring? end |
#sudo_expire! ⇒ Object
41 42 43 |
# File 'lib/hello/rails_active_record/access.rb', line 41 def sudo_expire! update! sudo_expires_at: 1.second.ago end |