Sha256: 362e80a1b8567445013396946d483b2df940e3c9bf4b3829ac491a1f85c7ded8
Contents?: true
Size: 632 Bytes
Versions: 3
Compression:
Stored size: 632 Bytes
Contents
module CompositePrimaryKeys ID_SEP = ',' ID_SET_SEP = ';' module ArrayExtension def to_composite_keys CompositeKeys.new(self) end end class CompositeKeys < Array def self.parse(value) case value when Array value.to_composite_keys when String self.new(value.split(ID_SEP)) else raise(ArgumentError, "Unsupported type: #{value}") end end def to_s # Doing this makes it easier to parse Base#[](attr_name) join(ID_SEP) end end end Array.send(:include, CompositePrimaryKeys::ArrayExtension)
Version data entries
3 entries across 3 versions & 1 rubygems