Sha256: 01d8cc1f917cd09d090e3cf5b6d43e1047c40722c74edc15a79d7b32ce06604e

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

module Masks
  module Actors
    # An anonymous actor, used for cases where deemed acceptable.
    #
    # @see Masks::Actor
    class Anonymous < ApplicationModel
      include Masks::Actor

      attribute :session

      # Generates and returns random nickname for the actor.
      #
      # @return [String]
      def nickname
        @nickname ||= "anon:#{SecureRandom.hex}"
      end

      # @return [Array] an empty array, since no scopes are available to anonymous actors
      def scopes
        []
      end

      # This is a no-op for anonymous actors. It always returns true.
      #
      # @return [Boolean]
      def mask!
        true
      end

      # Mark this actor as anonymous.
      #
      # @return [Boolean]
      def anonymous?
        true
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masks-0.4.0 app/models/masks/actors/anonymous.rb
masks-0.3.2 app/models/masks/actors/anonymous.rb
masks-0.3.1 app/models/masks/actors/anonymous.rb
masks-0.3.0 app/models/masks/actors/anonymous.rb
masks-0.2.0 app/models/masks/actors/anonymous.rb