rearmed_rails 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: 7d4600628a08453dea6e8e8a177982331c765a13
4
- data.tar.gz: 52efe76a55f2cfcbdf428d4019fb67fcdc5110a5
3
+ metadata.gz: 5d2e1474fe0711ea54cf256d3954b9254c4e8e01
4
+ data.tar.gz: 26d6c3cb7c20f65d5568019d4be2c4335af2dabe
5
5
  SHA512:
6
- metadata.gz: 9d2bb730931f1d2ac2db064f858931a88118cf8855198fa18e789e54bb91d9c42f62a793891071ea9499edff68157f401feec40ed8451e1b8dc518a9a5c31474
7
- data.tar.gz: 484eb3af4136de98b5a5a9075f3c2ca1c5b51b2147b664ab701ca55b6d28507335a6754941b2f626bd40fa2e3b58835a9aa4097ce8da1c8e973ee52f7ffa1ea8
6
+ metadata.gz: 461717a406c59c914ad5f66fa2955efb0678aaf8926a315d733a41f134f40dfaab46433f3a923beec00dc947b626ccd2aa1def8bdfb1f841033af074f6105547
7
+ data.tar.gz: aa3ce67201167bf2ba223043118fb992db82300c277c021ca14c87d76b3f90daa6aaed0ef19d5200aa63afe935a1581afb06df69efb24a3c4851968806ef829b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
+ - **1.0.5 - August 3, 2017**
5
+ - Fix `options_for_select_include_blank` & `options_for_select_include_blank` for Rails 5.1+ and improved them to patch in safer way
4
6
  - **1.0.4 - July 19, 2017**
5
7
  - Fix error in `find_duplicates` method
6
8
  - **1.0.3 - May 3, 2017**
@@ -55,57 +55,35 @@ if defined?(ActionView::Helpers)
55
55
 
56
56
  if enabled || RearmedRails.dig(RearmedRails.enabled_patches, :rails, :helpers, :options_for_select_include_blank)
57
57
  def options_for_select(container, selected = nil)
58
- return container if String === container
59
-
60
58
  if selected.is_a?(Hash)
61
59
  include_blank = selected[:include_blank] || selected['include_blank']
62
60
  end
63
61
 
64
- selected, disabled = extract_selected_and_disabled(selected).map do |r|
65
- Array(r).map(&:to_s)
66
- end
67
-
68
- options = []
62
+ options = super
69
63
 
70
64
  if include_blank
71
65
  include_blank = '' if include_blank == true
72
- options.push(content_tag_string(:option, include_blank, {value: ''}))
73
- end
74
66
 
75
- container.each do |element|
76
- html_attributes = option_html_attributes(element)
77
- text, value = option_text_and_value(element).map(&:to_s)
78
-
79
- html_attributes[:selected] ||= option_value_selected?(value, selected)
80
- html_attributes[:disabled] ||= disabled && option_value_selected?(value, disabled)
81
- html_attributes[:value] = value
67
+ if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 1
68
+ str = tag_builder.content_tag_string(:option, include_blank, {value: ''})
69
+ else
70
+ str = content_tag_string(:option, include_blank, {value: ''})
71
+ end
82
72
 
83
- options.push content_tag_string(:option, text, html_attributes)
73
+ options.prepend(str)
84
74
  end
85
75
 
86
- options.join("\n").html_safe
76
+ options
87
77
  end
88
78
  end
89
79
 
90
- if enabled || RearmedRails.dig(RearmedRails.enabled_patches, :rails, :helpers, :options_from_collection_for_select_include_blank)
80
+ if enabled || RearmedRails.dig(RearmedRails.enabled_patches, :rails, :helpers, :options_for_select_include_blank)
91
81
  def options_from_collection_for_select(collection, value_method, text_method, selected = nil)
92
82
  options = collection.map do |element|
93
83
  [value_for_collection(element, text_method), value_for_collection(element, value_method), option_html_attributes(element)]
94
84
  end
95
85
 
96
- if selected.is_a?(Hash)
97
- include_blank = selected[:include_blank] || selected['include_blank']
98
- end
99
-
100
- selected, disabled = extract_selected_and_disabled(selected)
101
-
102
- select_deselect = {
103
- selected: extract_values_from_collection(collection, value_method, selected),
104
- disabled: extract_values_from_collection(collection, value_method, disabled),
105
- include_blank: include_blank
106
- }
107
-
108
- options_for_select(options, select_deselect)
86
+ options_for_select(options, selected)
109
87
  end
110
88
  end
111
89
  end
@@ -1,3 +1,3 @@
1
1
  module RearmedRails
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rearmed_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-19 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake