module Wyrm::PumpMaker

Public Instance Methods

call_or_self( maybe_callable ) click to toggle source
# File lib/wyrm/pump_maker.rb, line 6
def call_or_self( maybe_callable )
  if maybe_callable.respond_to? :call
    maybe_callable.call( self )
  else
    maybe_callable
  end
end
make_pump( db, pump_thing ) click to toggle source
# File lib/wyrm/pump_maker.rb, line 14
def make_pump( db, pump_thing )
  call_or_self(pump_thing) || Wyrm::Pump.new( db: db )
end
maybe_deebe( db_or_string ) click to toggle source
# File lib/wyrm/pump_maker.rb, line 18
def maybe_deebe( db_or_string )
  case db_or_string
  when String
    begin
      Sequel.connect db_or_string
    rescue Sequel::AdapterNotFound
      raise "\nCan't find db driver for #{db_or_string}. It might work to do\n\n  gem install #{db_or_string.split(?:).first}\n\n"
    end
  when Sequel::Database
    db_or_string
  else
    raise "Don't know how to db-ify #{db_or_string.inspect}"
  end
end