Class: Tama::Memory::EntityParams
- Inherits:
-
Data
- Object
- Data
- Tama::Memory::EntityParams
- Defined in:
- lib/tama/memory/entity_params.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#validate_record ⇒ Object
readonly
Returns the value of attribute validate_record.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(identifier:, record:, validate_record: true) ⇒ EntityParams
constructor
A new instance of EntityParams.
- #to_h ⇒ Object
Constructor Details
#initialize(identifier:, record:, validate_record: true) ⇒ EntityParams
Returns a new instance of EntityParams.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tama/memory/entity_params.rb', line 6 def initialize(identifier:, record:, validate_record: true) unless identifier.is_a?(String) && !identifier.empty? raise Error::ValidationError.new("identifier is required", errors: {identifier: "must be a non-empty string"}) end unless record.is_a?(Hash) raise Error::ValidationError.new("record is required", errors: {record: "must be a hash"}) end unless [true, false].include?(validate_record) raise Error::ValidationError.new("validate_record must be boolean", errors: {validate_record: "must be boolean"}) end super end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier
5 6 7 |
# File 'lib/tama/memory/entity_params.rb', line 5 def identifier @identifier end |
#record ⇒ Object (readonly)
Returns the value of attribute record
5 6 7 |
# File 'lib/tama/memory/entity_params.rb', line 5 def record @record end |
#validate_record ⇒ Object (readonly)
Returns the value of attribute validate_record
5 6 7 |
# File 'lib/tama/memory/entity_params.rb', line 5 def validate_record @validate_record end |
Class Method Details
Instance Method Details
#to_h ⇒ Object
29 30 31 |
# File 'lib/tama/memory/entity_params.rb', line 29 def to_h {"identifier" => identifier, "record" => record, "validate_record" => validate_record} end |