record_view_helper 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 484e0e2bc1f93978d015d58e826dec01598b1297d1dec6e4dbf30b9b4bf04d77
4
- data.tar.gz: b56a7796e056fd245510ded3c773fd625b4d4c2000d9a88f9a5016d24761ab9f
3
+ metadata.gz: 4420c07571bd973a842e61399f37f2bb7952adb94e8d2357ebb4efae7c414bbe
4
+ data.tar.gz: 0caed0c7ee861e30ee80458ae99c9f67c0c61f70187f4ef1e1e9d69ba6bdcb6b
5
5
  SHA512:
6
- metadata.gz: 5473baa96d7ac03c39cb5ea4b9db5f728961980a093775b0e9803f5485ef2f0629bdcbdfafaa5ca28b55885a3583599f10aec5d8651c9708035e71cdaa853a45
7
- data.tar.gz: 8d19a02261b49c17d17d4bcab66368e0527d653f5f8fde03aa41b6f63b27adb2e692adb8ea9042d47fd564ec48e979e1f8e06e10a8775738b74ac56811ec9361
6
+ metadata.gz: ab18c5d000ca4f3db2eea7be853d681a3fbcdfd8889233615f5fb5c42eb6a20ada4933374971cb1936ea4e780545a23317bb6a6d587c5469fd030818ecc6a040
7
+ data.tar.gz: ca8de4b08691838a187562233290a1b1d0621b202af3ab51c6f517389b1dda06a3250e4bc25bccdba3e57f857f57ac1e48daffb5f275949964bd0eeb25b5a716
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/object/try"
2
+
1
3
  module RecordViewHelper
2
4
  # build definition list(dl) for records
3
5
  #
@@ -10,8 +12,8 @@ module RecordViewHelper
10
12
  # @return [ActiveSupport::SafeBuffer] rendered result
11
13
  def dl_for(record, options = {}) # rubocop:disable Metrics/AbcSize
12
14
  setting = RecordValueSetting.build_from_hash!(
13
- record.attributes.keys,
14
- record.class.name.tableize,
15
+ record.try(:attributes).try(:keys) || record.keys,
16
+ record.class.try(:name).try(:tableize),
15
17
  options,
16
18
  )
17
19
  yield setting if block_given?
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/object/try"
2
+
1
3
  module RecordViewHelper
2
4
  # build table for records
3
5
  # @param [Enumerable<Object>] records records
@@ -55,8 +57,8 @@ module RecordViewHelper
55
57
  # / see RecordValueSetting for details
56
58
  def table_for(records, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
57
59
  setting = RecordValueSetting.build_from_hash!(
58
- records.first.attributes.keys,
59
- records.first.class.name.tableize,
60
+ records.try(:klass).try(:column_names) || records.first.try(:attributes).try(:keys) || records.first.try(:keys) || [],
61
+ records.first.try(:class).try(:name).try(:tableize),
60
62
  options,
61
63
  )
62
64
  yield setting if block_given?
@@ -1,4 +1,4 @@
1
1
  module RecordViewHelper
2
2
  # version
3
- VERSION = "1.1.0".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_view_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-12 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview