Class: Ace::Assign::Models::Assignment
- Inherits:
-
Object
- Object
- Ace::Assign::Models::Assignment
- Defined in:
- lib/ace/assign/models/assignment.rb
Overview
Assignment data model representing a workflow assignment.
Pure data carrier with no business logic (ATOM pattern). All attributes are immutable after initialization.
NOTE: Could be refactored to use Data.define in Ruby 3.2+ for reduced boilerplate, but tests would need to be updated to provide all required fields.
Instance Attribute Summary collapse
-
#cache_dir ⇒ Object
readonly
Returns the value of attribute cache_dir.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#source_config ⇒ Object
readonly
Returns the value of attribute source_config.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
-
.from_h(data, cache_dir: nil) ⇒ Assignment
Create from hash (YAML deserialization).
Instance Method Summary collapse
-
#assignment_file ⇒ String
Path to assignment.yaml file.
-
#initialize(id:, name:, created_at:, source_config:, description: nil, updated_at: nil, cache_dir: nil, parent: nil) ⇒ Assignment
constructor
A new instance of Assignment.
-
#reports_dir ⇒ String
Path to reports directory.
-
#steps_dir ⇒ String
Path to steps directory.
-
#to_h ⇒ Hash
Convert to hash for YAML serialization.
Constructor Details
#initialize(id:, name:, created_at:, source_config:, description: nil, updated_at: nil, cache_dir: nil, parent: nil) ⇒ Assignment
Returns a new instance of Assignment.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ace/assign/models/assignment.rb', line 32 def initialize(id:, name:, created_at:, source_config:, description: nil, updated_at: nil, cache_dir: nil, parent: nil) @id = id.freeze @name = name.freeze @description = description&.freeze @created_at = created_at @updated_at = updated_at || created_at @source_config = source_config.freeze @cache_dir = cache_dir&.freeze @parent = parent&.freeze end |
Instance Attribute Details
#cache_dir ⇒ Object (readonly)
Returns the value of attribute cache_dir.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def cache_dir @cache_dir end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def parent @parent end |
#source_config ⇒ Object (readonly)
Returns the value of attribute source_config.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def source_config @source_config end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
22 23 24 |
# File 'lib/ace/assign/models/assignment.rb', line 22 def updated_at @updated_at end |
Class Method Details
.from_h(data, cache_dir: nil) ⇒ Assignment
Create from hash (YAML deserialization)
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ace/assign/models/assignment.rb', line 61 def self.from_h(data, cache_dir: nil) new( id: data["session_id"], name: data["name"], description: data["description"], created_at: parse_time(data["created_at"]), updated_at: parse_time(data["updated_at"]), source_config: data["source_config"], cache_dir: cache_dir, parent: data["parent"] ) end |
Instance Method Details
#assignment_file ⇒ String
Returns Path to assignment.yaml file.
89 90 91 92 93 |
# File 'lib/ace/assign/models/assignment.rb', line 89 def assignment_file return nil unless cache_dir File.join(cache_dir, "assignment.yaml") end |
#reports_dir ⇒ String
Returns Path to reports directory.
82 83 84 85 86 |
# File 'lib/ace/assign/models/assignment.rb', line 82 def reports_dir return nil unless cache_dir File.join(cache_dir, "reports") end |
#steps_dir ⇒ String
Returns Path to steps directory.
75 76 77 78 79 |
# File 'lib/ace/assign/models/assignment.rb', line 75 def steps_dir return nil unless cache_dir File.join(cache_dir, "steps") end |
#to_h ⇒ Hash
Convert to hash for YAML serialization
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ace/assign/models/assignment.rb', line 45 def to_h { "session_id" => id, "name" => name, "description" => description, "created_at" => created_at.iso8601, "updated_at" => updated_at.iso8601, "source_config" => source_config, "parent" => parent }.compact end |