Class: Clickwrap::SystemActor
- Inherits:
-
Object
- Object
- Clickwrap::SystemActor
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #clickwrap_actor_reference ⇒ Object
- #hash ⇒ Object
- #id ⇒ Object
-
#initialize(name) ⇒ SystemActor
constructor
A new instance of SystemActor.
- #persisted? ⇒ Boolean
- #to_s ⇒ Object
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
#name ⇒ Object (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_reference ⇒ Object
23 |
# File 'lib/clickwrap/system_actor.rb', line 23 def clickwrap_actor_reference = "system/#{name}" |
#hash ⇒ Object
29 |
# File 'lib/clickwrap/system_actor.rb', line 29 def hash = [self.class, name].hash |
#id ⇒ Object
24 |
# File 'lib/clickwrap/system_actor.rb', line 24 def id = name |
#persisted? ⇒ Boolean
26 |
# File 'lib/clickwrap/system_actor.rb', line 26 def persisted? = false |
#to_s ⇒ Object
25 |
# File 'lib/clickwrap/system_actor.rb', line 25 def to_s = clickwrap_actor_reference |