data_attributes 1.2.0 → 1.3.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/data_attributes/helper.rb +19 -15
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d8119bf8ee46fe7debce8d0c0954782fe03f778
4
- data.tar.gz: 161233cf2a8f90ea6883b30620511bbe751d169e
3
+ metadata.gz: 55f227bc4334e44d47f850c52b47b6bed500c41a
4
+ data.tar.gz: 17c65041fafabed28fce083f0377b5bc84b57534
5
5
  SHA512:
6
- metadata.gz: 8d7fdedbb0ce5dba5aef6ab1d46d1e18b926a402ea0a078df5852f75c511fb89a736c491820b712ee277c0ed557de2ee3f34f9c6d1fbd424f9921988775934d9
7
- data.tar.gz: 2b8e03dc415786e5d9906394acb8d03fe2e70f77d7b95805a3e645e2297e35b0a3acab87ece724d27e066d5de2202cd36f8a1530ec2d82b2bf8833a0fd405ed4
6
+ metadata.gz: 3f570b310459285ca3cef0c993fd75fbc8761fb48cf5d9de21b7a71edfd99195eea51f1278bb2ed12b1543b62f69805c40a329632afd6d8763e46eaa715303c7
7
+ data.tar.gz: 8e9e45890a74c13268f800c4029825b7671c2359f7e7f07b1ec05d2efbef7943679079045d2fa70bd7399b0eab0713202a68af9139a1163928af9d990f2862bd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -2,21 +2,7 @@ module DataAttributes
2
2
 
3
3
  module Helper
4
4
 
5
- def content_tag_for_single_record(tag_name, record, prefix, options, &block)
6
- options, prefix = prefix, nil if prefix.is_a?(Hash)
7
- options ||= {}
8
- options[:data] ||= {}
9
- options[:data] = options[:data].data_attributes if options[:data].is_a?(DataAttributes::Model)
10
- options[:data].reverse_merge!(record.data_attributes) if record.is_a?(DataAttributes::Model)
11
- options.reverse_merge!(class: record.class.model_name.singular.dasherize)
12
- if block.arity == 0
13
- content_tag(tag_name, capture(&block), options)
14
- else
15
- content_tag(tag_name, capture(record, &block), options)
16
- end
17
- end
18
-
19
- def data_attribute_value(value, options = {})
5
+ def self.data_attribute_value(value, options = {})
20
6
  if value.is_a?(String) || value.is_a?(Symbol)
21
7
  options[:prefix_strings] ? "string:#{value}" : value.to_s
22
8
  elsif value.is_a?(Numeric)
@@ -42,6 +28,24 @@ module DataAttributes
42
28
  end
43
29
  end
44
30
 
31
+ def content_tag_for_single_record(tag_name, record, prefix, options, &block)
32
+ options, prefix = prefix, nil if prefix.is_a?(Hash)
33
+ options ||= {}
34
+ options[:data] ||= {}
35
+ options[:data] = options[:data].data_attributes if options[:data].is_a?(DataAttributes::Model)
36
+ options[:data].reverse_merge!(record.data_attributes) if record.is_a?(DataAttributes::Model)
37
+ options.reverse_merge!(class: record.class.model_name.singular.dasherize)
38
+ if block.arity == 0
39
+ content_tag(tag_name, capture(&block), options)
40
+ else
41
+ content_tag(tag_name, capture(record, &block), options)
42
+ end
43
+ end
44
+
45
+ def data_attribute_value(value, options = {})
46
+ DataAttributes::Helper.data_attribute_value(value, options)
47
+ end
48
+
45
49
  def tag_options(options, escape = true)
46
50
  (options.delete(:data) || options.delete('data') || {}).each do |key, value|
47
51
  value = data_attribute_value(value)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.5.1
167
+ rubygems_version: 2.5.2
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Provides HTML data attributes from model to view