Sha256: 067dee9ee3358f89ef2c9cc97bb96482e556ef3712e95825889b0ddbe8bbdde9
Contents?: true
Size: 534 Bytes
Versions: 3
Compression:
Stored size: 534 Bytes
Contents
module RelationToStruct::ActiveRecordRelationExtension extend ::ActiveSupport::Concern def to_structs(struct_class) raise '' unless self.select_values.present? relation = spawn result = klass.connection.select_all(relation.arel, nil, relation.arel.bind_values + bind_values) result.cast_values(klass.column_types) result.cast_values(klass.column_types).map do |tuple| struct_class.new(*tuple) end end end ::ActiveRecord::Relation.send(:include, RelationToStruct::ActiveRecordRelationExtension)
Version data entries
3 entries across 3 versions & 1 rubygems