Method: Oinky::ValuesEnumerator.from_opt

Defined in:
lib/oinky/query.rb

.from_opt(opt) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/oinky/query.rb', line 14

def self.from_opt(opt)
  # These are column references.
  if opt.is_a? Symbol
    opt = opt.to_s
  end
  if opt.is_a? String
    # Turn this into a proc that extracts the selected value.
    cn = opt
    opt = lambda {|row| row[cn]}
  end

  raise OinkyException.new("ArgumentError - Invalid proc") unless opt.is_a? Proc
  return opt
end