activeitem 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54985c6329129ceac142d8f176c14dfcc68548992f7e00d54a116592ee2a9276
4
- data.tar.gz: abee89f1984d42b3dd72991c5db573370ed356d4272be0bb0d4d21163a233f50
3
+ metadata.gz: 2706d94d7f88c19fdb9fc14d8a9408d1f8dc088a5eabf2e583d60351173b9870
4
+ data.tar.gz: 41c8e00d8b5a45ec26b58123efc86437795e1921c59dc8c44f3a770727496702
5
5
  SHA512:
6
- metadata.gz: 456eb037d79395d8a63916245a681af7ad4a98a933cb294226658bf532886a7feb4fa2f90a2593cd1df34d4b5abd6d9299b206af2ad72cb96a5f1aa4ce1d3334
7
- data.tar.gz: a0626e95bf4d42f4b1f1c0c453223e50214cbad0be8de67e76539f42ff2c3449027bf78f62a6708303db14195c10558972b9715e7c2f9bbf95c080b5d4bcf509
6
+ metadata.gz: 41689642db2d18371ae7f9c7987a72d001f3aa18d5e7bb3f0a7248100e5de2a8aa6cb039742057c176bfb6f9eeaa02a240847d50c64f6f02c54372da6c069020
7
+ data.tar.gz: 5c1a35c85c0b6d641fd630681fccb4995637eb733c50eada9a197a1c2fd503cc62855c1ad14eb81e19ccf324e1da2941ab93cbf87b72e5116285b8b5e49ed7a8
@@ -374,6 +374,39 @@ module ActiveItem
374
374
  record
375
375
  end
376
376
 
377
+ # Build a new record with the foreign key pre-set (does not save).
378
+ # Usage: conversation.messages.build(role: "user", body: "hello")
379
+ # @param attributes [Hash] Attributes for the new record
380
+ # @return [ActiveItem::Base] The unsaved record
381
+ def build(attributes = {})
382
+ foreign_key, foreign_value = conditions.first
383
+ resolved_model.new(attributes.merge(foreign_key => foreign_value))
384
+ end
385
+
386
+ # Build and save a new record with the foreign key pre-set.
387
+ # Returns the record (may be invalid — check .persisted? or .errors).
388
+ # Usage: conversation.messages.create(role: "user", body: "hello")
389
+ # @param attributes [Hash] Attributes for the new record
390
+ # @return [ActiveItem::Base] The record (saved if valid)
391
+ def create(attributes = {})
392
+ record = build(attributes)
393
+ record.save
394
+ reload
395
+ record
396
+ end
397
+
398
+ # Build and save a new record with the foreign key pre-set.
399
+ # Raises ActiveItem::RecordInvalid if validations fail.
400
+ # Usage: conversation.messages.create!(role: "user", body: "hello")
401
+ # @param attributes [Hash] Attributes for the new record
402
+ # @return [ActiveItem::Base] The persisted record
403
+ def create!(attributes = {})
404
+ record = build(attributes)
405
+ record.save!
406
+ reload
407
+ record
408
+ end
409
+
377
410
  # Returns the DynamoDB operation that would be executed, without running it.
378
411
  # Analogous to ActiveRecord's .to_sql — shows the operation type, table, index,
379
412
  # key conditions, filters, and limits in DynamoDB terms.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveItem
4
- VERSION = '0.0.14'
4
+ VERSION = '0.0.15'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeitem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-08-03 00:00:00.000000000 Z
12
+ date: 2026-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel