Method: ActiveItemModel#initialize
- Defined in:
- ext/ruby/qtruby/rails_support/active_item_model.rb
#initialize(collection, columns = nil) ⇒ ActiveItemModel
Returns a new instance of ActiveItemModel.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 87 def initialize(collection, columns=nil) super() @collection = collection @keys = build_keys([], @collection.first.attributes) @keys.inject(@labels = {}) do |labels, k| labels[k] = k.humanize.gsub(/\./, ' ') labels end @rootItem = TreeItem.new(@labels, @keys) @collection.each do |row| TreeItem.new(row, @keys, @rootItem) end end |