This document provides an overview of the three standalone data modeling libraries included in Solid::Process: Solid::Model, Solid::Value, and Solid::Input. These libraries can be used independently of the process execution framework and provide ActiveModel-based data objects with varying characteristics and use cases.
For detailed information about each library's features, see:
For information about how inputs are used within processes, see Input Definition and Validation.
The three libraries form a hierarchy where Solid::Model provides the foundation for both Solid::Input and Solid::Value.
Sources: lib/solid/model.rb1-47 lib/solid/input.rb1-5
| Feature | Solid::Model | Solid::Value | Solid::Input |
|---|---|---|---|
| Primary Use Case | General-purpose data objects | Immutable value objects | Process input validation |
| Attributes | Multiple named attributes | Single value attribute or multiple | Multiple named attributes |
| Mutability | Mutable | Immutable | Mutable |
| Equality | Identity-based (default) | Value-based | Identity-based (default) |
| Hash Key Usage | Not recommended | Yes, works as hash keys | Not recommended |
| Instantiation | .new(...) or .[](...) | .[](value) | .new(...) or .[](...) |
| Process Integration | Not used directly | Not used directly | Created by input do...end DSL |
| Standalone Usage | Yes | Yes | Yes |
Sources: lib/solid/model.rb1-47 lib/solid/input.rb1-5 docs/overview/090_INTERNAL_LIBRARIES.md1-98
All three libraries include Solid::Model, which in turn includes several ActiveModel modules. The inclusion is conditional based on ActiveModel version:
The conditional inclusion ensures compatibility across Rails 6.0 through 8.1+:
ActiveModel::Api vs ActiveModel::Model (lib/solid/model.rb19)ActiveModel::Access vs Solid::Model::Access (lib/solid/model.rb20)ActiveModel::Attributes::Normalization if available (lib/solid/model.rb24-26)Sources: lib/solid/model.rb18-30 test/solid/model/class_test.rb62-88
Solid::Model provides a complete ActiveModel-based object with multiple named attributes, validations, callbacks, and dirty tracking.
| Feature | Description | Example Syntax |
|---|---|---|
| Attributes | Typed attributes with defaults | attribute :name, :string |
| Validations | Full ActiveModel validations | validates :email, presence: true |
| Callbacks | Before/after validation | before_validation { ... } |
| Dirty Tracking | Change detection | person.name_changed? |
| Bracket Access | Hash-style attribute access | person[:name] |
| Bracket Constructor | Alternative instantiation | Person[name: 'Alice'] |
| Initialize Callback | After-initialize hook | after_initialize { ... } |
Sources: lib/solid/model.rb1-47 test/solid/model/class_test.rb6-60 docs/overview/090_INTERNAL_LIBRARIES.md11-29
Solid::Value extends Solid::Model to create immutable value objects with value-based equality. Objects with the same values are considered equal and can be used as hash keys.
| Feature | Description |
|---|---|
| Value Equality | Objects with same values are equal |
| Hash Key Support | Works as dictionary keys |
| Single Value | Primary use case wraps one value |
| Multi-Attribute | Supports multiple attributes |
| Immutability | Cannot be modified after creation |
Sources: docs/overview/090_INTERNAL_LIBRARIES.md31-67
Solid::Input is a specialized version of Solid::Model designed specifically for process inputs. It is automatically created when using the input do...end DSL in a process class.
The implementation is minimal - it simply includes Solid::Model:
Sources: lib/solid/input.rb1-5 docs/overview/090_INTERNAL_LIBRARIES.md69-83
All three libraries support the bracket constructor syntax [] as an alternative to .new():
This provides a concise syntax for instantiation:
Sources: lib/solid/model.rb8-11
When a class including Solid::Model is inherited, the subclass automatically includes Solid::Model again:
This ensures all subclasses have the full Solid::Model behavior even if they inherit from a parent that included it.
Sources: lib/solid/model.rb13-15
Solid::Model defines an after_initialize callback that runs after object instantiation:
This allows classes to define post-initialization logic:
Sources: lib/solid/model.rb31-40 test/solid/model/class_test.rb6-20
Solid::Model provides a readable inspect output showing all attributes:
Example output:
Sources: lib/solid/model.rb42-44
The [] method is aliased to public_send to enable hash-style attribute access:
This allows treating model objects like hashes:
Combined with ActiveModel::Access (or Solid::Model::Access for older Rails), this also provides .slice() and other hash-like methods.
Sources: lib/solid/model.rb46 docs/overview/090_INTERNAL_LIBRARIES.md27-28
All three libraries can be used either:
input do...end and deps do...end DSLsSources: lib/solid/model.rb1-47 lib/solid/input.rb1-5 docs/overview/090_INTERNAL_LIBRARIES.md1-98
| Use Case | Recommended Library | Reason |
|---|---|---|
| Process input validation | Solid::Input | Automatic integration with input do...end |
| Domain value objects | Solid::Value | Value equality and hash key support |
| Form objects | Solid::Model or Solid::Input | Full validation and Rails form integration |
| Configuration objects | Solid::Model | Typed attributes with defaults |
| Dictionary keys | Solid::Value | Value-based equality |
| Immutable data | Solid::Value | Immutability enforced |
| Complex data structures | Solid::Model | Multiple attributes with relationships |
Sources: docs/overview/090_INTERNAL_LIBRARIES.md1-98
Within Solid::Process, the input do...end DSL automatically generates an Input constant that inherits from Solid::Input:
The generated input class can be accessed directly:
Similarly, deps do...end generates a Dependencies constant that includes Solid::Model.
Sources: docs/overview/040_ADVANCED_USAGE.md1-89 docs/overview/060_TESTING.md59-64
Refresh this wiki