Method: ROM::Mapper::AttributeDSL#unfold
- Defined in:
- lib/rom/mapper/attribute_dsl.rb
#unfold(name, options = EMPTY_HASH) ⇒ Object
Define an embedded hash attribute that requires “unfold” transformation
Typically this is used in non-sql context to convert array of values (like in Cassandra ‘SET’ or ‘LIST’ types) to array of tuples.
Source values are assigned to the first key, the other keys being left blank.
300 301 302 303 304 305 306 307 308 |
# File 'lib/rom/mapper/attribute_dsl.rb', line 300 def unfold(name, = EMPTY_HASH) (name, ) do || old_name = .fetch(:from, name) dsl(old_name, type: :array, unfold: true) do attribute name, yield if block_given? end end end |