spark_components 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spark_components/element.rb +9 -15
- data/lib/spark_components/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: 8fe4b2f67b278a268d99b228cba7b17eb7309c5e2ac8fadf1fff01f9e160e41f
|
4
|
+
data.tar.gz: 27ffcdd80392e749bbbbe7fa200f112086388f959f877a7adc18342f22a0f539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0c99f05d18e7bbf5c9ed044d6886b8b0b754a5dfbf9cf3d4e435d993128cf13dc108aac6c08326a773a7eb08744b54c11dbb0ded835fc7345a87903251911a4
|
7
|
+
data.tar.gz: ebebbc531b4214fa05e2c5bf19b02a7355439880d14cc2af839350269b6a0ba6b8aae3ffde023e4325328c65403721ab62ac0a29364011d556084a4ccc2fe23b
|
@@ -67,20 +67,14 @@ module SparkComponents
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.validates_choice(name, choices, required: true)
|
70
|
+
choices = choices.dup
|
70
71
|
choices = [choices] unless choices.is_a?(Array)
|
71
72
|
supported_choices = choices.map { |c| c.is_a?(String) ? c.to_sym : c.to_s }.concat(choices)
|
72
73
|
|
73
|
-
unless required
|
74
|
-
# Allow nil if option is not required
|
75
|
-
supported_choices.unshift(nil)
|
76
|
-
# Add `nil` to the error messsages list of valid options
|
77
|
-
choices.push("nil")
|
78
|
-
end
|
79
|
-
|
80
74
|
choices = choices.to_sentence(last_word_connector: ", or ")
|
81
75
|
message = "\"%<value>s\" is not valid. Options for #{name} include: #{choices}"
|
82
76
|
|
83
|
-
validates(name, inclusion: { in: supported_choices, message: message })
|
77
|
+
validates(name, inclusion: { in: supported_choices, message: message }, allow_blank: !required)
|
84
78
|
end
|
85
79
|
|
86
80
|
# rubocop:disable Metrics/AbcSize
|
@@ -94,7 +88,7 @@ module SparkComponents
|
|
94
88
|
component = "#{component}_component".classify.constantize if component.is_a?(String)
|
95
89
|
|
96
90
|
elements[name] = {
|
97
|
-
multiple: plural_name || false, class: Class.new(component || Element, &config)
|
91
|
+
multiple: plural_name || false, class: Class.new((component || Element), &config)
|
98
92
|
}
|
99
93
|
|
100
94
|
define_method_or_raise(name) do |attributes = nil, &block|
|
@@ -155,10 +149,6 @@ module SparkComponents
|
|
155
149
|
validate!
|
156
150
|
end
|
157
151
|
|
158
|
-
def render_block(&block)
|
159
|
-
block_given? ? @view.capture(self, &block) : nil
|
160
|
-
end
|
161
|
-
|
162
152
|
def after_init; end
|
163
153
|
|
164
154
|
def before_render; end
|
@@ -215,6 +205,12 @@ module SparkComponents
|
|
215
205
|
@yield.blank?
|
216
206
|
end
|
217
207
|
|
208
|
+
private
|
209
|
+
|
210
|
+
def render_block(&block)
|
211
|
+
block_given? ? @view.capture(self, &block) : nil
|
212
|
+
end
|
213
|
+
|
218
214
|
protected
|
219
215
|
|
220
216
|
# Set tag attribute values from from parameters
|
@@ -258,8 +254,6 @@ module SparkComponents
|
|
258
254
|
end
|
259
255
|
end
|
260
256
|
|
261
|
-
private
|
262
|
-
|
263
257
|
# Define common view methods to "alias"
|
264
258
|
def view_methods
|
265
259
|
%i[tag content_tag image_tag concat content_for link_to component capture]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spark_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|