The accessed_columns plugin records which columns have been accessed for a model instance. This is useful if you are looking to remove other columns from being SELECTed by the dataset that retrieved the instance, which can significantly improve performance:
a = Album[1] a.accessed_columns # [] a.name a.accessed_columns # [:name] a.artist_id a.accessed_columns # [:name, :artist_id]
Note that this plugin should probably not be used in production, as it causes a performance hit.
Usage:
# Make all model subclass instances record accessed columns (called before loading subclasses) Sequel::Model.plugin :accessed_columns # Make the Album instances record accessed columns Album.plugin :accessed_columns