Class: Clickwrap::SystemActor

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/system_actor.rb

Overview

A named non-human actor, for seeds, imports, migrations, and background processes. Recording one is how a system-created record says out loud that no person did this, instead of leaving a gap that later reads like a human action nobody can find.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ SystemActor

Returns a new instance of SystemActor.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/clickwrap/system_actor.rb', line 11

def initialize(name)
  @name = name.to_s

  if @name.strip.empty?
    raise ArgumentError,
          "A system actor needs a name describing what created the record, for example " \
          "\"database_seed\" or \"crm_import_2026_08\"."
  end

  freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/clickwrap/system_actor.rb', line 9

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



27
# File 'lib/clickwrap/system_actor.rb', line 27

def ==(other) = other.is_a?(self.class) && other.name == name

#clickwrap_actor_referenceObject



23
# File 'lib/clickwrap/system_actor.rb', line 23

def clickwrap_actor_reference = "system/#{name}"

#hashObject



29
# File 'lib/clickwrap/system_actor.rb', line 29

def hash = [self.class, name].hash

#idObject



24
# File 'lib/clickwrap/system_actor.rb', line 24

def id = name

#persisted?Boolean

Returns:

  • (Boolean)


26
# File 'lib/clickwrap/system_actor.rb', line 26

def persisted? = false

#to_sObject



25
# File 'lib/clickwrap/system_actor.rb', line 25

def to_s = clickwrap_actor_reference