lib/luna_park/extensions/repositories/postgres/read.rb in luna_park-0.13.0 vs lib/luna_park/extensions/repositories/postgres/read.rb in luna_park-0.13.1
- old
+ new
@@ -23,9 +23,18 @@
def find(pk_value, **scope)
read_one scoped(**scope).where(primary_key => pk_value)
end
+ def reload!(entity, **scope)
+ new_rows = scoped(**scope).where(primary_key => entity.public_send(primary_key))
+ found! new_rows, not_found_by: { primary_key => entity.public_send(primary_key)}
+
+ new_attrs = from_row __one_from__ new_rows
+ entity.set_attributes(new_attrs)
+ entity
+ end
+
def count(**scope)
scoped(**scope).count
end
def all(**scope)