activeitem 0.0.25 → 0.0.27

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: b0d54a71884d6a3e6796d735d765c66811fdb607e2e87d9b79434d44f8f237f4
4
- data.tar.gz: a655f7f62c60f2b436da2ab4b70e8e7096504879a468b32ee63f61dbefc34fa5
3
+ metadata.gz: 1c11222732807109d8a6fb40c6e6471005443ec071ad575595c9c5e4de53af4a
4
+ data.tar.gz: d96ab28bb664c7f471e29badc04ab3d48fc441a985fc3211616044cb0c397c9d
5
5
  SHA512:
6
- metadata.gz: 380e6f8230e48a0945e0de9634bf2ebbbac50174e219837e256785fbcce538315f5ad99fb9e5325e6eb279f3b1c75a8039c9a4a01b83f4e10d715bc9bdb83ae6
7
- data.tar.gz: 5999d960661a94ed2e3ae632323964cb5801050fe17b9cf96f83816107a54c7b7728e7dd2fa09139b4549c8b16d1be13ba559c1ee2e1ea9b921e59829cd36038
6
+ metadata.gz: 622690879edcc3362a1003ac71037e3d2582e9d11e45146b9840eb7473850b76025397d4757ce8ced6b30e58933ee16be9c9d4a5ec56eb454861d24c32cdf7df
7
+ data.tar.gz: 42b0c3bd56c5f3e5411844ae073f75397389c241baf9da8aff8aa43331270d32b6630c4015eb6b8cbea64b79e32244da06d15d716b50a7d3d575d492937cb4cb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.27
4
+
5
+ ### Added
6
+
7
+ - **Atomic counters: `Model.update_counters`, `#increment!`, `#decrement!`** (Fizzy #2075). `save` SETs the value the record read, so concurrent `opens + 1` saves lost counts and apps hand-wrote `update_item` with `ADD`. These send one UpdateItem that ADDs to the stored value, map names through `to_dynamo_key`, set `updatedAt` (and `createdAt` / `_recent_pk` if missing; `touch: false` skips them), and rebuild the record from `ALL_NEW`.
8
+
9
+ ```ruby
10
+ ShareLink.update_counters(id, opens: 1, visitors: 1) # upserts, like ADD
11
+ ShareLink.update_counters(id, { opens: 1 }, if_exists: true) # nil when the row is missing
12
+ link.increment!(:opens, :visitors, set: { last_opened_at: t }, set_if_missing: { first_opened_at: t })
13
+ ```
14
+
15
+ `increment!` only touches a row that still exists (returns `false` otherwise), and leaves the touched attributes clean. Undeclared names passed to `update_counters` are used verbatim as DynamoDB attribute names. AccessDenied is wrapped in `ActiveItem::AccessDeniedError`.
16
+
17
+ ## 0.0.26
18
+
19
+ Scope hardening from the Posh Nosh security review (Fizzy #2004). Several of these change behavior; see **Changed**.
20
+
21
+ ### Fixed
22
+
23
+ - **`accepts_nested_attributes_for` could update or destroy any child by id.** Nested rows were looked up with an unscoped `find`, so a parent could edit or `_destroy` another parent's child. A row whose foreign key isn't this parent's now raises `ActiveItem::RecordNotFound`, and the foreign key can no longer be reassigned through nested attributes (it is stripped and re-asserted on update and create).
24
+ - **A mass-assigned `id` redirected an update to another row.** `record.update(params)` with an `id` in the hash wrote the changes onto that other row. Changing the primary key of a persisted record now raises `ActiveItem::ReadonlyAttributeError`; assigning the same id back (form round-trips) is still allowed.
25
+ - **`relation.find(id)` only checked the first `where` condition.** Every condition and `where.not` condition is now checked. Conditions that can't be evaluated in Ruby with DynamoDB's semantics (ranges, nested paths) are checked by a filtered query instead. Preloaded (`includes`) and `has_many :through` relations, and `where(id: [...])`, find only among their loaded records. `none.find` and a nil-key association's `find` raise instead of returning any row. Preloaded `has_many` relations also keep the owner condition, so `where`/`exists?`/`reload` on them stay scoped.
26
+ - **`ilike: true` loosened every string condition in the relation.** `where(tenant_id: t).where(name: q, ilike: true)` substring-matched `tenant_id` too. ilike now applies per attribute.
27
+ - **Creating inside `Model.transaction` silently replaced an existing row.** The transactional put now carries the same `attribute_not_exists` condition as a normal create.
28
+ - **Filtered lookups on unindexed attributes made one Scan per item.** `find_by`, `exists?`, `limit`, `count` and uniqueness validation sent the wanted result count as DynamoDB's `Limit`, which applies *before* the filter. `Limit` is now only sent when there is no filter (scan, query, count, fan-out, pagination and `explain`); results are still trimmed to the limit.
29
+ - Paginated GSI queries could skip items when a page was trimmed; the next cursor now always resumes after the last returned item.
30
+
31
+ ### Changed
32
+
33
+ - `where(..., ilike: :name)` / `ilike: [:name, :sku]` names the attributes to match case-insensitively. `ilike: true` still works when that `where` call has exactly one string condition, and raises `ArgumentError` when it has several. `Relation#ilike` is now a boolean; the attribute list is `Relation#ilike_attributes`.
34
+ - A transactional create on an existing key now fails the whole transaction with `ActiveItem::TransactionError` at commit, instead of overwriting. Explicit `txn.put(record)` is unchanged (still an upsert); it now also accepts `expression_attribute_names:` alongside `condition:`.
35
+ - Nested attributes naming another parent's child raise `ActiveItem::RecordNotFound` from `save`.
36
+
3
37
  ## 0.0.25
4
38
 
5
39
  ### Fixed
data/README.md CHANGED
@@ -87,6 +87,37 @@ lowercased characters and whose sort key is the whole lowercased value, then
87
87
  `begins_with` on the sort key. `begins_with` on a non-key attribute works too, but
88
88
  it's a filter, so DynamoDB still reads every item in the query or scan.
89
89
 
90
+ ### Counters
91
+
92
+ `save` SETs the value the record read, so two requests saving `opens + 1` at
93
+ once lose one. Counters use one UpdateItem with DynamoDB's `ADD` instead, which
94
+ adds to whatever is stored:
95
+
96
+ ```ruby
97
+ ShareLink.update_counters(id, opens: 1, visitors: 1) # no read; creates the row if missing
98
+ ShareLink.update_counters(id, { opens: 1 }, if_exists: true) # nil instead of creating a row
99
+ ShareLink.update_counters(id, { opens: 1 }, set: { last_opened_at: t }, set_if_missing: { first_opened_at: t })
100
+
101
+ link.increment!(:opens) # refreshed from the stored row
102
+ link.increment!(:opens, :visitors, by: 2, set: { last_opened_at: t })
103
+ link.decrement!(:stock) # negative amounts work too
104
+ ```
105
+
106
+ - `update_counters` returns the row as stored after the update, or `nil` when
107
+ `if_exists: true` and the row is missing. Without `if_exists` a missing row is
108
+ created holding just the counters (that's how `ADD` works).
109
+ - `increment!` / `decrement!` only update a row that still exists. They return
110
+ the record, or `false` if the row was deleted. The touched attributes are
111
+ refreshed and left clean; other unsaved changes are kept.
112
+ - `set:` SETs attributes in the same write (`nil` removes one), and
113
+ `set_if_missing:` SETs only attributes that are absent (`if_not_exists`).
114
+ - Every write sets `updatedAt`, and sets `createdAt` and `_recent_pk` if missing.
115
+ `update_counters(..., touch: false)` leaves all three out.
116
+ - Declared attributes map through `to_dynamo_key` / `dynamo_attribute_map`. Class-level
117
+ names that aren't declared attributes are used verbatim, e.g.
118
+ `update_counters(day, 'n:page:/pricing' => 1)`.
119
+ - Counters don't run validations or callbacks, and aren't enrolled in `transaction`.
120
+
90
121
  ### Associations
91
122
 
92
123
  ```ruby
@@ -266,22 +266,35 @@ module ActiveItem
266
266
  next unless assoc_config
267
267
 
268
268
  target_class = safe_constantize_model(assoc_config[:class_name])
269
- foreign_key = assoc_config[:foreign_key]
269
+ foreign_key = assoc_config[:foreign_key].to_s
270
+ owner_key = send(assoc_config[:primary_key])
271
+
272
+ # Only children that already belong to this parent can be updated or destroyed
273
+ find_child = lambda do |child_id|
274
+ child = target_class.find(child_id)
275
+ unless child.send(foreign_key) == owner_key
276
+ raise ActiveItem::RecordNotFound,
277
+ "Couldn't find #{target_class.name} with id=#{child_id} for #{self.class.name} with #{assoc_config[:primary_key]}=#{owner_key}"
278
+ end
279
+
280
+ child
281
+ end
270
282
 
271
283
  config[:records].each do |attrs|
272
284
  attrs = attrs.transform_keys(&:to_sym)
273
285
 
274
286
  if attrs[:_destroy] && config[:allow_destroy]
275
- if attrs[:id]
276
- record = target_class.find(attrs[:id])
277
- record.destroy!
278
- end
287
+ find_child.call(attrs[:id]).destroy! if attrs[:id]
279
288
  elsif attrs[:id]
280
- record = target_class.find(attrs[:id])
281
- record.assign_attributes(attrs.except(:id, :_destroy))
289
+ record = find_child.call(attrs[:id])
290
+ record.assign_attributes(attrs.except(:id, :_destroy, foreign_key.to_sym))
291
+ # Re-assert the owner: an alias writer (e.g. <association>_id=) could have moved it
292
+ record.send("#{foreign_key}=", owner_key)
282
293
  record.save!
283
294
  else
284
- target_class.create!(attrs.merge(foreign_key.to_sym => id))
295
+ record = target_class.new(attrs.except(:_destroy))
296
+ record.send("#{foreign_key}=", owner_key)
297
+ record.save!
285
298
  end
286
299
  end
287
300
  end
@@ -302,12 +315,16 @@ module ActiveItem
302
315
  config = self.class._associations[name]
303
316
  return Relation.new(Object, conditions: { _empty: true }) unless config
304
317
 
305
- return Relation.new(nil, preloaded_records: _preloaded_associations[name], class_name: config[:class_name]) if _preloaded_associations.key?(name)
306
-
307
318
  local_key_value = send(config[:primary_key])
308
319
  return Relation.new(nil, conditions: { _empty: true }, class_name: config[:class_name]) if local_key_value.nil?
309
320
 
310
321
  conditions = { config[:foreign_key].to_sym => local_key_value }
322
+
323
+ # Preloaded records keep the owner condition, so where/reload/build on them stay scoped
324
+ if _preloaded_associations.key?(name)
325
+ return Relation.new(nil, preloaded_records: _preloaded_associations[name], conditions: conditions,
326
+ index_name: config[:index], class_name: config[:class_name], owner: self)
327
+ end
311
328
  relation = Relation.new(nil, conditions: conditions, index_name: config[:index],
312
329
  class_name: config[:class_name], owner: self)
313
330
 
@@ -18,6 +18,7 @@ module ActiveItem
18
18
  include Associations
19
19
  include Embeddable
20
20
  include Logging
21
+ include Counters
21
22
 
22
23
  define_model_callbacks :save, :create, :update, :destroy, :initialize, :validation
23
24
 
@@ -35,7 +36,15 @@ module ActiveItem
35
36
  attr_accessor :created_at, :updated_at, :dbrecord
36
37
 
37
38
  def id=(value)
38
- @id = (value.to_s.strip.empty? ? nil : value)
39
+ value = nil if value.to_s.strip.empty?
40
+ # Re-assigning the same id (forms send it back) is fine; changing it is not.
41
+ if persisted?
42
+ return if value.to_s == @id.to_s
43
+
44
+ raise ReadonlyAttributeError, "#{self.class.primary_key} can't be changed on a persisted #{self.class.name}"
45
+ end
46
+
47
+ @id = value
39
48
  end
40
49
 
41
50
  before_create :generate_primary_key
@@ -169,6 +178,8 @@ module ActiveItem
169
178
  def to_dynamo_key(attr_name)
170
179
  attr_str = attr_name.to_s
171
180
  return dynamo_attribute_map[attr_str] if dynamo_attribute_map.key?(attr_str)
181
+ # The primary key is stored under its own name (see build_dynamodb_item)
182
+ return attr_str if attr_str == primary_key.to_s
172
183
 
173
184
  attr_str.camelize(:lower)
174
185
  end
@@ -592,7 +603,11 @@ module ActiveItem
592
603
 
593
604
  result = run_callbacks :save do
594
605
  if new_record?
595
- run_callbacks(:create) { txn.put(self) }
606
+ # Same guard as perform_create: a create must not replace an existing row
607
+ run_callbacks(:create) do
608
+ txn.put(self, condition: 'attribute_not_exists(#pk)',
609
+ expression_attribute_names: { '#pk' => self.class.primary_key.to_s })
610
+ end
596
611
  else
597
612
  run_callbacks(:update) { txn.update(self) }
598
613
  end
@@ -0,0 +1,187 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveItem
4
+ # Atomic counters: one UpdateItem that ADDs to numeric attributes, so two
5
+ # writers incrementing at the same time both count. `save` can't do this; it
6
+ # SETs the value the record read.
7
+ #
8
+ # @example Class level, no read; creates the row if it's missing
9
+ # ShareLink.update_counters(id, opens: 1, visitors: 1)
10
+ #
11
+ # @example Only touch a row that exists
12
+ # ShareLink.update_counters(id, { opens: 1 }, if_exists: true) # => nil when missing
13
+ #
14
+ # @example Instance level, refreshes the record from the stored row
15
+ # link.increment!(:opens, set: { last_opened_at: t }, set_if_missing: { first_opened_at: t })
16
+ # link.decrement!(:stock, by: 2)
17
+ module Counters
18
+ def self.included(base)
19
+ base.extend(ClassMethods)
20
+ end
21
+
22
+ # Class-level counter API.
23
+ module ClassMethods
24
+ # ADD `counters` to the row with this id in one UpdateItem, without reading
25
+ # it first. Amounts may be negative.
26
+ #
27
+ # Declared attributes are mapped through `to_dynamo_key`; any other name
28
+ # (e.g. "n:page:/pricing") is used as the DynamoDB attribute name verbatim.
29
+ # `updatedAt` is set, and `createdAt` and `_recent_pk` are set only if
30
+ # missing, unless `touch: false`.
31
+ #
32
+ # @param set [Hash] attributes to SET alongside the counters (nil REMOVEs)
33
+ # @param set_if_missing [Hash] attributes to SET only if absent (if_not_exists)
34
+ # @param if_exists [Boolean] condition on the row existing instead of creating it
35
+ # @param touch [Boolean] false leaves updatedAt, createdAt and _recent_pk alone
36
+ # @return [ActiveItem::Base, nil] the row as stored after the update, or nil
37
+ # when `if_exists: true` and there is no such row
38
+ def update_counters(id, counters = nil, set: {}, set_if_missing: {}, if_exists: false, touch: true, **more_counters)
39
+ counters = (counters || {}).merge(more_counters)
40
+ item = counter_update_item(id, counters, set: set, set_if_missing: set_if_missing, if_exists: if_exists, touch: touch)
41
+ item && instantiate(item)
42
+ end
43
+
44
+ private
45
+
46
+ # Runs the UpdateItem and returns the raw ALL_NEW item, or nil when the
47
+ # `if_exists` condition failed.
48
+ def counter_update_item(id, counters, set:, set_if_missing:, if_exists:, touch: true)
49
+ raise_embedded_error!(:update_counters) if respond_to?(:embedded?) && embedded?
50
+ raise ArgumentError, 'update_counters needs an id' if id.nil? || id.to_s.empty?
51
+ raise ArgumentError, 'update_counters needs at least one counter' if counters.empty?
52
+
53
+ dynamodb.update_item(counter_update_params(id, counters, set, set_if_missing, if_exists, touch)).attributes
54
+ rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException
55
+ raise unless if_exists
56
+
57
+ nil
58
+ rescue Aws::DynamoDB::Errors::AccessDeniedException => e
59
+ raise_access_denied('UpdateItem', e)
60
+ end
61
+
62
+ def counter_update_params(id, counters, set, set_if_missing, if_exists, touch)
63
+ names = {}
64
+ values = {}
65
+ sets = []
66
+ removes = []
67
+ adds = []
68
+ claimed = {}
69
+ claim = lambda do |name|
70
+ dynamo_key = counter_dynamo_key(name)
71
+ raise ArgumentError, "#{dynamo_key} appears more than once in update_counters" if claimed.key?(dynamo_key)
72
+
73
+ claimed[dynamo_key] = true
74
+ placeholder = "#a#{claimed.size}"
75
+ names[placeholder] = dynamo_key
76
+ placeholder
77
+ end
78
+
79
+ claimed[primary_key.to_s] = true
80
+ timestamps = touch ? { 'updatedAt' => '#updatedAt', 'createdAt' => '#createdAt', '_recent_pk' => '#recentPk' } : {}
81
+ timestamps.each_key { |key| claimed[key] = true }
82
+
83
+ counters.each do |name, amount|
84
+ raise ArgumentError, "counter #{name} needs a numeric amount, got #{amount.inspect}" unless amount.is_a?(Numeric)
85
+
86
+ placeholder = claim.call(name)
87
+ values[":#{placeholder[1..]}"] = amount
88
+ adds << "#{placeholder} :#{placeholder[1..]}"
89
+ end
90
+
91
+ set.each do |name, value|
92
+ placeholder = claim.call(name)
93
+ if value.nil?
94
+ removes << placeholder
95
+ else
96
+ values[":#{placeholder[1..]}"] = value
97
+ sets << "#{placeholder} = :#{placeholder[1..]}"
98
+ end
99
+ end
100
+
101
+ set_if_missing.each do |name, value|
102
+ raise ArgumentError, "set_if_missing #{name} needs a value" if value.nil?
103
+
104
+ placeholder = claim.call(name)
105
+ values[":#{placeholder[1..]}"] = value
106
+ sets << "#{placeholder} = if_not_exists(#{placeholder}, :#{placeholder[1..]})"
107
+ end
108
+
109
+ if touch
110
+ timestamps.each { |key, placeholder| names[placeholder] = key }
111
+ values[':now'] = Time.now.utc.iso8601
112
+ values[':recentPk'] = 'ALL'
113
+ sets.unshift('#updatedAt = :now', '#createdAt = if_not_exists(#createdAt, :now)',
114
+ '#recentPk = if_not_exists(#recentPk, :recentPk)')
115
+ end
116
+
117
+ expression = "ADD #{adds.join(', ')}"
118
+ expression = "SET #{sets.join(', ')} #{expression}" if sets.any?
119
+ expression += " REMOVE #{removes.join(', ')}" if removes.any?
120
+
121
+ params = {
122
+ table_name: table_name,
123
+ key: { primary_key.to_s => id },
124
+ update_expression: expression,
125
+ expression_attribute_names: names,
126
+ expression_attribute_values: values,
127
+ return_values: 'ALL_NEW'
128
+ }
129
+ if if_exists
130
+ names['#pk'] = primary_key.to_s
131
+ params[:condition_expression] = 'attribute_exists(#pk)'
132
+ end
133
+ params
134
+ end
135
+
136
+ # Declared (or explicitly mapped) attributes go through to_dynamo_key;
137
+ # anything else is already a DynamoDB attribute name.
138
+ def counter_dynamo_key(name)
139
+ name = name.to_s
140
+ return to_dynamo_key(name) if attribute_names.include?(name) || dynamo_attribute_map.key?(name)
141
+
142
+ name
143
+ end
144
+ end
145
+
146
+ # ADD `by` to each attribute on the stored row in one UpdateItem, then
147
+ # refresh those attributes (and the timestamps) from what was stored. The
148
+ # touched attributes are left clean; other unsaved changes are kept.
149
+ #
150
+ # Only updates a row that still exists: a deleted record is not brought
151
+ # back by its counter.
152
+ #
153
+ # @return [self, false] false when the row no longer exists
154
+ def increment!(*attributes, by: 1, set: {}, set_if_missing: {})
155
+ raise ArgumentError, 'increment! needs at least one attribute' if attributes.empty?
156
+ raise ArgumentError, "Cannot increment a new #{self.class.name}; save it first" if new_record?
157
+
158
+ attributes = attributes.map(&:to_s)
159
+ touched = attributes + set.keys.map(&:to_s) + set_if_missing.keys.map(&:to_s)
160
+ undeclared = touched - self.class.attribute_names
161
+ raise ArgumentError, "#{self.class.name} has no attribute #{undeclared.join(', ')}" if undeclared.any?
162
+
163
+ counters = attributes.to_h { |name| [name, by] }
164
+ item = self.class.send(:counter_update_item, id, counters, set: set, set_if_missing: set_if_missing, if_exists: true)
165
+ return false unless item
166
+
167
+ refresh_counter_attributes(item, touched)
168
+ self
169
+ end
170
+
171
+ # increment! with the amount negated.
172
+ def decrement!(*attributes, by: 1, set: {}, set_if_missing: {})
173
+ increment!(*attributes, by: -by, set: set, set_if_missing: set_if_missing)
174
+ end
175
+
176
+ private
177
+
178
+ def refresh_counter_attributes(item, touched)
179
+ fresh = self.class.instantiate(item)
180
+ touched.each { |name| instance_variable_set("@#{name}", fresh.instance_variable_get("@#{name}")) }
181
+ @created_at = fresh.created_at
182
+ @updated_at = fresh.updated_at
183
+ @dbrecord = fresh.dbrecord
184
+ clear_attribute_changes(touched)
185
+ end
186
+ end
187
+ end
@@ -42,7 +42,10 @@ module ActiveItem
42
42
 
43
43
  def scan(limit: nil, filter_expression: nil, expression_attribute_names: nil, expression_attribute_values: nil, projection_expression: nil)
44
44
  params = { table_name: table_name }
45
- params[:limit] = limit if limit
45
+ # DynamoDB applies Limit before the filter, so with a filter it caps items
46
+ # *read* per page, not matches; a small limit would then cost one request
47
+ # per item in the table. Only send it when there is no filter.
48
+ params[:limit] = limit if limit && !filter_expression
46
49
  params[:filter_expression] = filter_expression if filter_expression
47
50
  params[:expression_attribute_names] = expression_attribute_names if expression_attribute_names
48
51
  params[:expression_attribute_values] = expression_attribute_values if expression_attribute_values
@@ -69,7 +72,7 @@ module ActiveItem
69
72
  break if limit && items.length >= limit
70
73
  end
71
74
 
72
- items
75
+ limit ? items.first(limit) : items
73
76
  rescue Aws::DynamoDB::Errors::AccessDeniedException => e
74
77
  raise_access_denied('Scan', e)
75
78
  end
@@ -4,6 +4,11 @@ module ActiveItem
4
4
  class RecordNotFound < StandardError; end
5
5
  class TransactionError < StandardError; end
6
6
 
7
+ # Raised when assigning a different primary key to a persisted record.
8
+ # Writes are keyed on the id, so a mass-assigned id (record.update(params))
9
+ # would otherwise redirect the update to another row.
10
+ class ReadonlyAttributeError < StandardError; end
11
+
7
12
  # Raised by save! when validations fail.
8
13
  class RecordInvalid < StandardError
9
14
  attr_reader :record
@@ -166,6 +166,10 @@ module ActiveItem
166
166
  # @example Case-insensitive search (ilike option)
167
167
  # Container.where(name: 'box', ilike: true) # Substring match
168
168
  # Container.where(name: 'box', ilike: true, exact: true) # Exact case-insensitive
169
+ # Container.where(owner_id: id, name: 'box', ilike: :name) # Only name; owner_id stays exact
170
+ #
171
+ # ilike applies per attribute. ilike: true covers the single string condition in
172
+ # that where call and raises ArgumentError if there are several; name them instead.
169
173
  #
170
174
  # @example Batch find by primary key (automatically uses BatchGetItem)
171
175
  # Customer.where(customer_id: ['cust-1', 'cust-2', 'cust-3'])
@@ -179,7 +183,7 @@ module ActiveItem
179
183
 
180
184
  # Extract special options
181
185
  index_name = conditions.delete(:index) || conditions.delete(:index_name)
182
- ilike = conditions.delete(:ilike) || false
186
+ ilike = conditions.delete(:ilike)
183
187
  exact = conditions.delete(:exact) || false
184
188
 
185
189
  # Optimization: Detect primary key array queries and use batch_find
@@ -200,7 +204,8 @@ module ActiveItem
200
204
  end
201
205
  end
202
206
 
203
- Relation.new(self, conditions: conditions, index_name: index_name, ilike: ilike, ilike_exact: exact)
207
+ Relation.new(self, conditions: conditions, index_name: index_name,
208
+ ilike_attributes: Relation.resolve_ilike_attributes(ilike, conditions), ilike_exact: exact)
204
209
  end
205
210
 
206
211
  # Returns a Relation for all records (enables chaining from .all)
@@ -10,11 +10,40 @@ module ActiveItem
10
10
  include Enumerable
11
11
  include ModelLoader
12
12
 
13
- attr_reader :model, :conditions, :index_name, :limit_value, :not_conditions, :ilike, :ilike_exact, :class_name, :owner, :includes_associations,
14
- :order_direction, :select_attributes
13
+ attr_reader :model, :conditions, :index_name, :limit_value, :not_conditions, :ilike_attributes, :ilike_exact, :class_name, :owner,
14
+ :includes_associations, :order_direction, :select_attributes
15
15
 
16
- def initialize(model, conditions: {}, index_name: nil, limit_value: nil, not_conditions: {}, ilike: false, ilike_exact: false, class_name: nil,
17
- owner: nil, preloaded_records: nil, includes_associations: [], order_direction: nil, select_attributes: nil)
16
+ # Resolve a where call's `ilike:` option into the attribute names it applies to.
17
+ #
18
+ # ilike is per attribute so it never loosens a scope condition passed
19
+ # alongside it (where(tenant_id: t, name: q, ilike: true) must keep
20
+ # tenant_id exact).
21
+ #
22
+ # ilike: :name / ilike: [:name, :sku] -> those attributes
23
+ # ilike: true -> the one String condition in this call;
24
+ # raises if there is more than one
25
+ # ilike: nil / false -> none
26
+ def self.resolve_ilike_attributes(option, conditions)
27
+ return [] if option.nil? || option == false
28
+
29
+ if option == true
30
+ names = conditions.select { |_, v| v.is_a?(String) }.keys.map(&:to_sym)
31
+ if names.size > 1
32
+ raise ArgumentError, "ilike: true is ambiguous with several string conditions (#{names.join(', ')}); " \
33
+ "name the attribute instead, e.g. ilike: :#{names.last}"
34
+ end
35
+ return names
36
+ end
37
+
38
+ names = Array(option).map(&:to_sym)
39
+ unknown = names - conditions.keys.map(&:to_sym)
40
+ raise ArgumentError, "ilike names #{unknown.join(', ')}, which #{unknown.size == 1 ? 'is' : 'are'} not a condition in this where" if unknown.any?
41
+
42
+ names
43
+ end
44
+
45
+ def initialize(model, conditions: {}, index_name: nil, limit_value: nil, not_conditions: {}, ilike_attributes: [], ilike_exact: false,
46
+ class_name: nil, owner: nil, preloaded_records: nil, includes_associations: [], order_direction: nil, select_attributes: nil)
18
47
  @model = model
19
48
  @class_name = class_name # For lazy loading
20
49
  @owner = owner # The object that owns this association
@@ -22,7 +51,7 @@ module ActiveItem
22
51
  @index_name = index_name
23
52
  @limit_value = limit_value
24
53
  @not_conditions = not_conditions.dup
25
- @ilike = ilike # Use case-insensitive contains() for string conditions
54
+ @ilike_attributes = ilike_attributes # Attributes matched case-insensitively (substring unless ilike_exact)
26
55
  @ilike_exact = ilike_exact # Require exact case-insensitive match (Ruby-side filter)
27
56
  @loaded = preloaded_records ? true : false
28
57
  @records = preloaded_records
@@ -31,6 +60,11 @@ module ActiveItem
31
60
  @select_attributes = select_attributes # Projection expression attributes
32
61
  end
33
62
 
63
+ # Whether any condition is matched case-insensitively.
64
+ def ilike
65
+ ilike_attributes.any?
66
+ end
67
+
34
68
  # Whether the relation's records have been loaded from DynamoDB.
35
69
  def loaded?
36
70
  @loaded
@@ -75,10 +109,13 @@ module ActiveItem
75
109
  new_ilike = new_conditions.delete(:ilike)
76
110
  new_exact = new_conditions.delete(:exact)
77
111
 
112
+ # A condition re-specified here drops any earlier ilike on that attribute
113
+ kept_ilike = new_ilike == false ? [] : ilike_attributes - new_conditions.keys.map(&:to_sym)
114
+
78
115
  spawn(
79
116
  conditions: conditions.merge(new_conditions),
80
117
  index_name: new_index || index_name,
81
- ilike: new_ilike.nil? ? ilike : new_ilike,
118
+ ilike_attributes: kept_ilike | Relation.resolve_ilike_attributes(new_ilike, new_conditions),
82
119
  ilike_exact: new_exact.nil? ? ilike_exact : new_exact
83
120
  )
84
121
  end
@@ -331,15 +368,32 @@ module ActiveItem
331
368
  # Delegate to Enumerable#find when block is given (Rails behavior)
332
369
  to_a.find(&)
333
370
  elsif id
371
+ not_found = "Couldn't find #{resolved_model.name} with id=#{id}"
372
+ raise ActiveItem::RecordNotFound, not_found if conditions[:_empty]
373
+
374
+ # A loaded relation (preloaded association, has_many :through,
375
+ # where(id: [...])) is its own scope: look in the loaded records.
376
+ if @loaded
377
+ record = @records.find { |r| r.id.to_s == id.to_s }
378
+ raise ActiveItem::RecordNotFound, not_found unless record
379
+
380
+ return record
381
+ end
382
+
334
383
  # Use direct GetItem instead of scanning — O(1) vs O(n)
335
384
  record = resolved_model.find(id)
336
385
 
337
- # When called on an association (has conditions), validate scope
338
- # This ensures @project.epics.find(id) only returns epics belonging to @project
339
- if conditions.any? && !conditions[:_empty]
340
- foreign_key, expected_value = conditions.first
341
- actual_value = record.send(foreign_key)
342
- raise ActiveItem::RecordNotFound, "Couldn't find #{resolved_model.name} with id=#{id}" unless actual_value == expected_value
386
+ # Every condition and not-condition must hold, so @project.epics.find(id)
387
+ # only returns epics belonging to @project. Conditions we can't evaluate
388
+ # in Ruby (nested paths, ranges, ...) are checked by DynamoDB instead.
389
+ case scope_verdict(record)
390
+ when false
391
+ raise ActiveItem::RecordNotFound, not_found
392
+ when nil
393
+ pk = resolved_model.primary_key.to_sym
394
+ record = spawn(conditions: conditions.merge(pk => record.id), limit_value: nil, select_attributes: nil,
395
+ includes_associations: []).to_a.first
396
+ raise ActiveItem::RecordNotFound, not_found unless record
343
397
  end
344
398
 
345
399
  preload_associations_for_records([record]) if includes_associations.any?
@@ -477,7 +531,7 @@ module ActiveItem
477
531
  parts = []
478
532
  parts << "conditions=#{conditions.inspect}" if conditions.any?
479
533
  parts << "not_conditions=#{not_conditions.inspect}" if not_conditions.any?
480
- parts << 'ilike=true' if ilike
534
+ parts << "ilike=#{ilike_attributes.inspect}" if ilike
481
535
  parts << 'exact=true' if ilike_exact
482
536
  "#<#{self.class.name} (not loaded) #{parts.join(' ')}>"
483
537
  end
@@ -507,7 +561,7 @@ module ActiveItem
507
561
  index_name: overrides.fetch(:index_name, index_name),
508
562
  limit_value: overrides.fetch(:limit_value, limit_value),
509
563
  not_conditions: overrides.fetch(:not_conditions, not_conditions),
510
- ilike: overrides.fetch(:ilike, ilike),
564
+ ilike_attributes: overrides.fetch(:ilike_attributes, ilike_attributes),
511
565
  ilike_exact: overrides.fetch(:ilike_exact, ilike_exact),
512
566
  class_name: overrides.fetch(:class_name, class_name),
513
567
  owner: overrides.fetch(:owner, owner),
@@ -527,13 +581,94 @@ module ActiveItem
527
581
  @resolved_model ||= safe_constantize_model(@class_name)
528
582
  end
529
583
 
584
+ # Whether a fetched record satisfies every condition and not-condition of
585
+ # this relation. Returns true/false, or nil when some condition can't be
586
+ # evaluated in Ruby with the same semantics DynamoDB would apply.
587
+ def scope_verdict(record)
588
+ normalize_conditions(conditions).each do |attr, expected|
589
+ result = condition_verdict(record, attr, expected, ilike: ilike_attribute?(attr))
590
+ return result unless result == true
591
+ end
592
+
593
+ normalize_conditions(not_conditions).each do |attr, expected|
594
+ # DynamoDB's <> / NOT IN on a missing attribute: let it decide
595
+ return nil if !expected.nil? && read_condition_attribute(record, attr).nil?
596
+
597
+ result = condition_verdict(record, attr, expected, ilike: false)
598
+ return nil if result.nil?
599
+ return false if result
600
+ end
601
+
602
+ true
603
+ end
604
+
605
+ # Ruby mirror of build_condition_expression for the value shapes whose
606
+ # semantics are unambiguous. Returns nil for anything else.
607
+ def condition_verdict(record, attr, expected, ilike:)
608
+ attr = attr.to_s
609
+ if expected.is_a?(ActiveItem::Base)
610
+ expected = expected.send(expected.class.primary_key)
611
+ attr = "#{attr}_id" unless attr.end_with?('_id')
612
+ end
613
+ return nil if attr.include?('.') || expected.is_a?(Hash) || expected.is_a?(Range)
614
+ return nil unless readable_condition_attribute?(record, attr)
615
+
616
+ actual = read_condition_attribute(record, attr)
617
+
618
+ if expected.nil?
619
+ actual.nil?
620
+ elsif ilike && expected.is_a?(String)
621
+ return false unless actual.is_a?(String)
622
+
623
+ ilike_exact ? actual.downcase == expected.downcase : actual.downcase.include?(expected.downcase)
624
+ elsif expected.is_a?(ActiveItem::BeginsWith)
625
+ actual.is_a?(String) && actual.start_with?(expected.prefix)
626
+ elsif expected.is_a?(Array)
627
+ return nil unless expected.all? { |v| scalar_condition_value?(v) }
628
+
629
+ expected.include?(actual)
630
+ elsif scalar_condition_value?(expected)
631
+ actual == expected
632
+ end
633
+ end
634
+
635
+ def scalar_condition_value?(value)
636
+ value.is_a?(String) || value.is_a?(Numeric) || value == true || value == false
637
+ end
638
+
639
+ def readable_condition_attribute?(record, attr)
640
+ attr == 'id' || attr == record.class.primary_key.to_s || record.class.attribute_names.include?(attr)
641
+ end
642
+
643
+ def read_condition_attribute(record, attr)
644
+ attr = attr.to_s
645
+ return record.id if attr == 'id' || attr == record.class.primary_key.to_s
646
+
647
+ record.instance_variable_get("@#{attr}")
648
+ end
649
+
650
+ # Set DynamoDB's Limit only when there is no filter. Limit caps the items
651
+ # *read* per page, before the filter runs, so a small limit with a
652
+ # selective filter turns into one request per item in the table/partition.
653
+ # Callers keep counting matches themselves and stop once they have enough.
654
+ def apply_scan_limit!(params, value)
655
+ params[:limit] = value if value && !params[:filter_expression]
656
+ end
657
+
658
+ # Whether a (normalized) condition attribute is matched case-insensitively
659
+ def ilike_attribute?(attr)
660
+ ilike_attributes.any? do |name|
661
+ name == attr.to_sym || (resolve_association_foreign_key(name.to_s) || name.to_s) == attr.to_s
662
+ end
663
+ end
664
+
530
665
  # Apply Ruby-side filter for case-insensitive matching
531
- # Called after DynamoDB query returns results when ilike is true
666
+ # Called after DynamoDB query returns results when ilike is set
532
667
  def apply_ilike_filter(records)
533
668
  return records unless ilike
534
669
 
535
- # Get the string conditions that need case-insensitive matching
536
- string_conditions = conditions.select { |_, v| v.is_a?(String) }
670
+ # Only the string conditions marked ilike get case-insensitive matching
671
+ string_conditions = conditions.select { |k, v| v.is_a?(String) && ilike_attributes.include?(k.to_sym) }
537
672
  return records if string_conditions.empty?
538
673
 
539
674
  records.select do |record|
@@ -680,7 +815,7 @@ module ActiveItem
680
815
 
681
816
  if remaining_conditions.any?
682
817
  remaining_conditions.each_with_index do |(attr, val), idx|
683
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
818
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
684
819
  filter_parts << expr
685
820
  params[:expression_attribute_names].merge!(names)
686
821
  params[:expression_attribute_values].merge!(values) if values.any?
@@ -705,8 +840,10 @@ module ActiveItem
705
840
 
706
841
  loop do
707
842
  params[:exclusive_start_key] = current_cursor if current_cursor
708
- # Fetch more than needed to reduce round trips when filter removes items
709
- params[:limit] = [per_page * 2, 100].min
843
+ # Fetch more than needed to reduce round trips when filter removes items.
844
+ # With a filter, read a full 100 per request so a tiny per_page can't
845
+ # turn into one request per item.
846
+ params[:limit] = params[:filter_expression] ? Pagination::MAX_PER_PAGE : [per_page * 2, 100].min
710
847
 
711
848
  response = resolved_model.dynamodb.query(params)
712
849
  items = response.items.map { |item| resolved_model.instantiate(item) }
@@ -722,15 +859,17 @@ module ActiveItem
722
859
 
723
860
  # Trim to requested page size and determine next cursor
724
861
  if collected_items.length > per_page
725
- next_cursor = last_evaluated_key || build_synthetic_cursor(collected_items[per_page - 1], idx_name, index_config)
862
+ # Resume right after the last returned item. last_evaluated_key points past
863
+ # the whole fetched page and would skip the trimmed items.
864
+ next_cursor = build_synthetic_cursor(collected_items[per_page - 1], idx_name, index_config)
726
865
  [collected_items.take(per_page), encode_cursor(next_cursor)]
727
866
  else
728
867
  [collected_items, encode_cursor(last_evaluated_key)]
729
868
  end
730
869
  end
731
870
 
732
- # Build a synthetic ExclusiveStartKey from an item when DynamoDB didn't paginate
733
- # but we have more items than per_page (overfetch returned everything in one shot).
871
+ # Build a synthetic ExclusiveStartKey from the last returned item when a
872
+ # page was trimmed to per_page, so the next page resumes right after it.
734
873
  # For GSI queries, DynamoDB requires: table PK + index partition key + index sort key (if any).
735
874
  def build_synthetic_cursor(item, _idx_name, index_config)
736
875
  pk_dynamo = resolved_model.to_dynamo_key(resolved_model.primary_key.to_s)
@@ -748,7 +887,7 @@ module ActiveItem
748
887
  filter_names = {}
749
888
 
750
889
  normalized_conditions.each_with_index do |(attr, val), idx|
751
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
890
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
752
891
  filter_parts << expr
753
892
  filter_names.merge!(names)
754
893
  filter_values.merge!(values) if values.any?
@@ -773,8 +912,10 @@ module ActiveItem
773
912
 
774
913
  loop do
775
914
  params[:exclusive_start_key] = current_cursor if current_cursor
776
- # Fetch more than needed to reduce round trips when filter removes items
777
- params[:limit] = [per_page * 2, 100].min
915
+ # Fetch more than needed to reduce round trips when filter removes items.
916
+ # With a filter, read a full 100 per request so a tiny per_page can't
917
+ # turn into one request per item.
918
+ params[:limit] = params[:filter_expression] ? Pagination::MAX_PER_PAGE : [per_page * 2, 100].min
778
919
 
779
920
  response = resolved_model.dynamodb.scan(params)
780
921
  items = response.items.map { |item| resolved_model.instantiate(item) }
@@ -851,7 +992,7 @@ module ActiveItem
851
992
  build_count_scan_params(normalized_conditions)
852
993
  end
853
994
  params[:exclusive_start_key] = exclusive_start_key if exclusive_start_key
854
- params[:limit] = limit_value if limit_value
995
+ apply_scan_limit!(params, limit_value)
855
996
 
856
997
  response = if effective_index && normalized_conditions.any?
857
998
  resolved_model.dynamodb.query(params)
@@ -948,7 +1089,7 @@ module ActiveItem
948
1089
  loop do
949
1090
  params = build_count_scan_params(normalized_conditions)
950
1091
  params[:exclusive_start_key] = exclusive_start_key if exclusive_start_key
951
- params[:limit] = limit_value if limit_value
1092
+ apply_scan_limit!(params, limit_value)
952
1093
 
953
1094
  response = resolved_model.dynamodb.scan(params)
954
1095
  total += response.count
@@ -1027,7 +1168,7 @@ module ActiveItem
1027
1168
 
1028
1169
  if remaining_conditions.any?
1029
1170
  remaining_conditions.each_with_index do |(attr, val), idx|
1030
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
1171
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
1031
1172
  filter_parts << expr
1032
1173
  params[:expression_attribute_names].merge!(names)
1033
1174
  params[:expression_attribute_values].merge!(values) if values.any?
@@ -1044,7 +1185,7 @@ module ActiveItem
1044
1185
  end
1045
1186
 
1046
1187
  params[:filter_expression] = filter_parts.join(' AND ') if filter_parts.any?
1047
- params[:limit] = limit_value if limit_value
1188
+ apply_scan_limit!(params, limit_value)
1048
1189
  params[:scan_index_forward] = (order_direction != :desc) unless order_direction.nil?
1049
1190
  apply_projection_expression!(params)
1050
1191
  params
@@ -1057,7 +1198,7 @@ module ActiveItem
1057
1198
  filter_values = {}
1058
1199
 
1059
1200
  normalized_conditions.each_with_index do |(attr, val), idx|
1060
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
1201
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
1061
1202
  filter_parts << expr
1062
1203
  filter_names.merge!(names)
1063
1204
  filter_values.merge!(values) if values.any?
@@ -1078,7 +1219,7 @@ module ActiveItem
1078
1219
  params[:expression_attribute_names] = filter_names if filter_names.any?
1079
1220
  params[:expression_attribute_values] = filter_values if filter_values.any?
1080
1221
  params[:projection_expression] = proj_expr if proj_expr
1081
- params[:limit] = limit_value if limit_value
1222
+ apply_scan_limit!(params, limit_value)
1082
1223
  params
1083
1224
  end
1084
1225
 
@@ -1188,7 +1329,7 @@ module ActiveItem
1188
1329
 
1189
1330
  if remaining_conditions.any?
1190
1331
  remaining_conditions.each_with_index do |(attr, val), idx|
1191
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
1332
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
1192
1333
  filter_parts << expr
1193
1334
  params[:expression_attribute_names].merge!(names)
1194
1335
  params[:expression_attribute_values].merge!(values) if values.any?
@@ -1206,7 +1347,7 @@ module ActiveItem
1206
1347
  end
1207
1348
 
1208
1349
  params[:filter_expression] = filter_parts.join(' AND ') if filter_parts.any?
1209
- params[:limit] = limit_value if limit_value
1350
+ apply_scan_limit!(params, limit_value)
1210
1351
  params[:scan_index_forward] = (order_direction != :desc) unless order_direction.nil?
1211
1352
 
1212
1353
  # Add projection expression if select() was used
@@ -1225,7 +1366,7 @@ module ActiveItem
1225
1366
  break if limit_value && all_items.length >= limit_value
1226
1367
  end
1227
1368
 
1228
- all_items
1369
+ limit_value ? all_items.first(limit_value) : all_items
1229
1370
  end
1230
1371
 
1231
1372
  # Fan-out parallel queries when partition key is an Array.
@@ -1254,7 +1395,7 @@ module ActiveItem
1254
1395
 
1255
1396
  apply_sort_key_to_params!(params, sort_key, remaining_conditions)
1256
1397
  params[:filter_expression] = filter_parts.join(' AND ') if filter_parts.any?
1257
- params[:limit] = limit_value if limit_value
1398
+ apply_scan_limit!(params, limit_value)
1258
1399
  params[:scan_index_forward] = (order_direction != :desc) unless order_direction.nil?
1259
1400
  apply_projection_expression!(params)
1260
1401
 
@@ -1375,7 +1516,7 @@ module ActiveItem
1375
1516
  end
1376
1517
 
1377
1518
  non_sort_conditions.each_with_index do |(attr, val), idx|
1378
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
1519
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
1379
1520
  filter_parts << expr
1380
1521
  filter_names.merge!(names)
1381
1522
  filter_values.merge!(values) if values.any?
@@ -1503,7 +1644,7 @@ module ActiveItem
1503
1644
  filter_names = {}
1504
1645
 
1505
1646
  normalized_conditions.each_with_index do |(attr, val), idx|
1506
- expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike)
1647
+ expr, names, values = resolved_model.send(:build_condition_expression, attr, val, idx, ilike: ilike_attribute?(attr))
1507
1648
  filter_parts << expr
1508
1649
  filter_names.merge!(names)
1509
1650
  filter_values.merge!(values) if values.any?
@@ -46,7 +46,9 @@ module ActiveItem
46
46
  !current.nil?
47
47
  end
48
48
 
49
- def put(record, condition: nil)
49
+ # @param condition [String, nil] ConditionExpression for the put
50
+ # @param expression_attribute_names [Hash, nil] Name placeholders used by +condition+
51
+ def put(record, condition: nil, expression_attribute_names: nil)
50
52
  record.instance_variable_set(:@id, SecureRandom.uuid) unless record.id
51
53
  pk = record.class.primary_key
52
54
  record.instance_variable_set(:"@#{pk}", record.id) if pk != 'id'
@@ -62,6 +64,7 @@ module ActiveItem
62
64
 
63
65
  op = { put: { table_name: record.class.table_name, item: item } }
64
66
  op[:put][:condition_expression] = condition if condition
67
+ op[:put][:expression_attribute_names] = expression_attribute_names if expression_attribute_names
65
68
 
66
69
  @operations << { op: op, record: record, type: :put }
67
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveItem
4
- VERSION = '0.0.25'
4
+ VERSION = '0.0.27'
5
5
  end
data/lib/activeitem.rb CHANGED
@@ -15,6 +15,7 @@ require_relative 'active_item/composed_of'
15
15
  require_relative 'active_item/validations'
16
16
  require_relative 'active_item/transaction'
17
17
  require_relative 'active_item/pagination'
18
+ require_relative 'active_item/counters'
18
19
  require_relative 'active_item/base'
19
20
 
20
21
  # ActiveRecord-style ORM for Amazon DynamoDB.
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.25
4
+ version: 0.0.27
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-11-02 00:00:00.000000000 Z
12
+ date: 2026-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -160,6 +160,7 @@ files:
160
160
  - lib/active_item/begins_with.rb
161
161
  - lib/active_item/composed_of.rb
162
162
  - lib/active_item/configuration.rb
163
+ - lib/active_item/counters.rb
163
164
  - lib/active_item/database_helpers.rb
164
165
  - lib/active_item/embeddable.rb
165
166
  - lib/active_item/embedded_collection.rb