Module: ActiveRecordExtension::ClassMethods
- Defined in:
- lib/active_record_extension.rb
Overview
add your static(class) methods here
Instance Method Summary collapse
Instance Method Details
#grab(which, what, options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_record_extension.rb', line 12 def grab(which,what,) pluck=Assist.make_string_list(what) unless [:swap].nil? swaps=[:swap] swaps.each_key { |key| index=what.index(key.to_sym) what[index]=swaps[key.to_sym] } end order=Assist.make_string_list([:sort]) unless .nil? || [: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 |