Method: Bmg::OutputPreferences#order_attrlist
- Defined in:
- lib/bmg/support/output_preferences.rb
#order_attrlist(attrlist) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bmg/support/output_preferences.rb', line 51 def order_attrlist(attrlist) return attrlist if attributes_ordering.nil? index = Hash[attributes_ordering.each_with_index.to_a] base = attrlist base = attrlist & attributes_ordering if extra_attributes == :ignored base.sort{|a,b| ai, bi = index[a], index[b] if ai && bi ai <=> bi elsif ai extra_attributes == :after ? -1 : 1 else extra_attributes == :after ? 1 : -1 end } end |