Sha256: 5b5a9850d7f2e86a6f5a2eb3cc0784c84335fc1012028770070f84497479bc88
Contents?: true
Size: 602 Bytes
Versions: 24
Compression:
Stored size: 602 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
24 entries across 24 versions & 1 rubygems