html_tables 0.0.10 → 0.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb98de4641af8daaf0649e633f1a76b38f96d78
4
- data.tar.gz: b6ca66edd261de6ea51f2d6f210a441e285067f9
3
+ metadata.gz: 00bbe3d09e255e86b9a2e5317394df3ce66d9fc1
4
+ data.tar.gz: a8651091f16dcff9b92e24ccedb950a1dc562df0
5
5
  SHA512:
6
- metadata.gz: b2e547ebb34b0f2d00b29ca4bf65f2df77302587525a5073af5e79f4623d95956cd3ed33702b9f9a66650cffa9d546cbd600b0c0a237ef2c9d238e7de68f028b
7
- data.tar.gz: 0f2e1e3bf088d925b3923830b9ef457ceb72c553d16ea51c832f26684885f4dd29b2cc34243516b44ba04fe7d4593a2588e0571e0cb70e1f92a201489161a3fe
6
+ metadata.gz: 66ad98813aed0275709e7beeb1b84601ed4d92e64033c01ea378c646b0a0f062e56c16f405a34c89900d49b17e32e62a64f7e5814286b7e03c763b17af3eac67
7
+ data.tar.gz: 7f8e2452b0f543989f876862e24db2a3d37e602e3beadc3c89923d04bf6eb3cc614355378efd6fe4b6838c98457d177c7e7a0ee62d37cb09ba49950411ac774d
@@ -21,11 +21,20 @@ module HtmlTables
21
21
  end
22
22
 
23
23
  def model
24
- @model ||= collection.model_name.constantize if collection.respond_to?(:model_name)
24
+ @model ||= begin
25
+ n = collection.model_name.constantize if collection.respond_to?(:model_name)
26
+ n = n.name if n.is_a?(ActiveModel::Name)
27
+ n
28
+ end
25
29
  @model ||= collection.first.try(:class)
26
30
  @model ||= options[:name].to_s.singularize.constantize
27
31
  end
28
32
 
33
+ def model_name
34
+ @model_name ||= collection.model_name if collection.respond_to?(:model_name)
35
+ @model_name ||= model.model_name
36
+ end
37
+
29
38
  def model_columns
30
39
  @model_columns ||= ActiveSupport::HashWithIndifferentAccess[*model.columns.map { |c| [c.name, c] }.flatten]
31
40
  end
@@ -44,7 +53,7 @@ module HtmlTables
44
53
  return @builder.content_tag(:i, nil, class: 'icon-check') if columns[column_id][:checkbox]
45
54
  v ||= I18n.t(column_id, scope: [:tables, options[:name] || :default], raise: true) rescue nil
46
55
  v ||= I18n.t(column_id, scope: [:tables, :default], raise: true) rescue nil
47
- v ||= I18n.t(column_id, scope: [:activerecord, :attributes, model.model_name.underscore], raise: true) rescue nil
56
+ v ||= I18n.t(column_id, scope: [:activerecord, :attributes, model_name.underscore], raise: true) rescue nil
48
57
  v ||= I18n.t(column_id, scope: [:attributes], raise: true) rescue nil
49
58
  v ||= model_columns[column_id].human_name rescue nil
50
59
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module HtmlTables
4
- VERSION = '0.0.10'
4
+ VERSION = '0.0.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fábio David Batista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-06 00:00:00.000000000 Z
11
+ date: 2013-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n