Sha256: 2d6e8f1fc148fb922a5735c7d337c8c62a2b9f0dd1f696245c7a3c8fa6b3381b

Contents?: true

Size: 950 Bytes

Versions: 7

Compression:

Stored size: 950 Bytes

Contents

module LatoCore

  # This module contains helpers for the superuser activerecord.
  module Superuser::EntityHelpers
    
    # This function save login informations for user.
    def save_login ip_address
      self.update(last_login_datetime: DateTime.now, last_login_ip_address: ip_address)
    end

    # This function return the permission name for the user.
    def get_permission_name
      permission = CONFIGS[:lato_core][:superusers_permissions].values.select{|x| x[:value] === self.permission}
      return permission[0][:title] if permission && !permission.empty?
    end

    # This function return the complete name for the user.
    def get_complete_name
      return "#{self.surname} #{self.name}"
    end

    # This function return a pretty string about the last login of the user.
    def get_pretty_last_login_datetime
      return self.last_login_datetime.strftime('%d/%m/%Y %H:%M') if self.last_login_datetime
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lato_core-2.2.2 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.2.0 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.1.4 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.1.3 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.1.2 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.1.1 app/models/lato_core/superuser/entity_helpers.rb
lato_core-2.1 app/models/lato_core/superuser/entity_helpers.rb