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 +4 -4
- data/lib/record_view_helper/dl.rb +4 -2
- data/lib/record_view_helper/table.rb +4 -2
- data/lib/record_view_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4420c07571bd973a842e61399f37f2bb7952adb94e8d2357ebb4efae7c414bbe
|
4
|
+
data.tar.gz: 0caed0c7ee861e30ee80458ae99c9f67c0c61f70187f4ef1e1e9d69ba6bdcb6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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?
|
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.
|
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-
|
11
|
+
date: 2018-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|