rails_slickgrid 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,22 @@ module RailsSlickgrid
2
2
  module ColumnExtractor
3
3
  extend self
4
4
  def from_data(data)
5
+ return from_hash_keys(data) if data.first.is_a? Hash
6
+ return from_ar_columns(data) if data.first.is_a? ActiveRecord::Base
7
+ return data
8
+ end
9
+
10
+ def from_hash_keys data
5
11
  data.first.keys.collect do |kee|
6
12
  {:id => kee, :name => kee.to_s.humanize, :field => kee}
7
13
  end
8
14
  end
15
+
16
+ def from_ar_columns data
17
+ # TODO: add size info
18
+ data.first.class.content_columns.collect do |col|
19
+ {:id => col.name, :name => col.name.to_s.humanize, :field => col.name}
20
+ end
21
+ end
9
22
  end
10
23
  end
@@ -1,3 +1,3 @@
1
1
  module RailsSlickgrid
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_slickgrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joe Martinez