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 +4 -4
- data/lib/active_item/relation.rb +33 -0
- data/lib/active_item/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2706d94d7f88c19fdb9fc14d8a9408d1f8dc088a5eabf2e583d60351173b9870
|
|
4
|
+
data.tar.gz: 41c8e00d8b5a45ec26b58123efc86437795e1921c59dc8c44f3a770727496702
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41689642db2d18371ae7f9c7987a72d001f3aa18d5e7bb3f0a7248100e5de2a8aa6cb039742057c176bfb6f9eeaa02a240847d50c64f6f02c54372da6c069020
|
|
7
|
+
data.tar.gz: 5c1a35c85c0b6d641fd630681fccb4995637eb733c50eada9a197a1c2fd503cc62855c1ad14eb81e19ccf324e1da2941ab93cbf87b72e5116285b8b5e49ed7a8
|
data/lib/active_item/relation.rb
CHANGED
|
@@ -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.
|
data/lib/active_item/version.rb
CHANGED
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.
|
|
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-
|
|
12
|
+
date: 2026-08-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activemodel
|