Sha256: a483d223dc02ce3634a8eb413c71b896d53e77bb1a88549c1b6f93cfa431799d
Contents?: true
Size: 666 Bytes
Versions: 1
Compression:
Stored size: 666 Bytes
Contents
require 'hirb' module Hirb::Views::Kangaroo def kangaroo__model__base_view obj { :fields => get_kangaroo_fields(obj) } end def get_kangaroo_fields obj fields = obj.class.attribute_names # if query used select if obj.attributes.keys.sort != obj.class.attribute_names.sort selected_columns = obj.attributes.keys sorted_columns = obj.class.attribute_names.dup.delete_if {|e| !selected_columns.include?(e) } sorted_columns += (selected_columns - sorted_columns) fields = sorted_columns.map {|e| e.to_sym} end [:id] + fields end end Hirb::DynamicView.add Hirb::Views::Kangaroo, :helper => :auto_table
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kangaroo-0.1.0.alpha1 | lib/kangaroo/hirb.rb |