Serialized values for indexed columns and drying up the serializing part a little too
✓ Published0🌍 Public
DDylanFM
Last edited Jul 27, 2011
Created on Jul 27, 2011
The diff shows a refactoring of a `Bagman` Ruby module, where a custom setter for indexed columns centralizes serialization logic. It introduces a `serialise_value` class method that handles both `options[:serialize]` procs and `Date`-to-`db` format, then assigns the result to both the index column and the `bag` hash. The change removes duplicate inline serialization code, simplifying the previous `if/elsif/else` block. This demonstrates a DRY (Don’t Repeat Yourself) approach for consistent value transformation in an ORM-like object, using Ruby’s `define_method` and attribute writers.
AI-generated description