data_attributes 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/data_attributes/helper.rb +19 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f227bc4334e44d47f850c52b47b6bed500c41a
|
4
|
+
data.tar.gz: 17c65041fafabed28fce083f0377b5bc84b57534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f570b310459285ca3cef0c993fd75fbc8761fb48cf5d9de21b7a71edfd99195eea51f1278bb2ed12b1543b62f69805c40a329632afd6d8763e46eaa715303c7
|
7
|
+
data.tar.gz: 8e9e45890a74c13268f800c4029825b7671c2359f7e7f07b1ec05d2efbef7943679079045d2fa70bd7399b0eab0713202a68af9139a1163928af9d990f2862bd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -2,21 +2,7 @@ module DataAttributes
|
|
2
2
|
|
3
3
|
module Helper
|
4
4
|
|
5
|
-
def
|
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.
|
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.
|
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
|