module ActiveRecordExtension::ClassMethods
add your static(class) methods here
Public Instance Methods
grab(which,what,options)
click to toggle source
# File lib/active_record_extension.rb, line 12 def grab(which,what,options) pluck=Assist.make_string_list(what) unless options[:swap].nil? swaps=options[:swap] swaps.each_key { |key| index=what.index(key.to_sym) what[index]=swaps[key.to_sym] } end order=Assist.make_string_list(options[:sort]) unless options.nil? || options[:sort].nil? if which=='all' order.nil? ? Assist.named_array(self.all.pluck(pluck),what) : Assist.named_array(self.all.order(order).pluck(pluck),what) else order.nil? ? Assist.named_array(self.where(which).pluck(pluck),what) : Assist.named_array(self.where(which).order(order).pluck(pluck),what) end end