Sha256: 0d403354eec8b604edd2591298dc3c6ffaa59b8594843ce180a03baa8516ff19
Contents?: true
Size: 794 Bytes
Versions: 4
Compression:
Stored size: 794 Bytes
Contents
#:nodoc: module Sequel #:nodoc: class Model ## # Retrieves all primary values and an optional column and returns the results as # an array of hashes in which the keys of these hashes are the IDs and the values # the values of the specified column. This array can be used when creating <select> # elements using the BlueForm helper. # # @example # Sections::Models::Section.pk_hash(:name) # => {1 => 'Blog', 2 => 'General'} # # @author Yorick Peterse # @param [Symbol] column The name of the optional column to select. # @return [Hash] # def self.pk_hash column hash = {} self.select(:id, column.to_sym).each do |row| hash[row.id] = row.send(column) end return hash end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
zen-0.2.4.1 | lib/zen/model/methods.rb |
zen-0.2.4 | lib/zen/model/methods.rb |
zen-0.2.3 | lib/zen/model/methods.rb |
zen-0.2 | lib/zen/model/methods.rb |