Skip to content

Commit 8774e7b

Browse files
committed
Drop support for rails versions < 5.2
1 parent 742dc12 commit 8774e7b

File tree

4 files changed

+17
-80
lines changed

4 files changed

+17
-80
lines changed

lib/helpers/recurring_select_helper.rb

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
module RecurringSelectHelper
44
module FormHelper
5-
if Rails::VERSION::MAJOR >= 4
6-
def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {})
7-
RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render
8-
end
9-
elsif Rails::VERSION::MAJOR == 3
10-
def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {})
11-
InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options)
12-
end
5+
def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {})
6+
RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render
137
end
148
end
159

@@ -96,51 +90,24 @@ def recurring_select_html_options(html_options)
9690
end
9791
end
9892

99-
if Rails::VERSION::STRING.to_f >= 4.0
100-
# === Rails 4
101-
class RecurringSelectTag < ActionView::Helpers::Tags::Base
102-
include RecurringSelectHelper::FormOptionsHelper
103-
include SelectHTMLOptions
104-
105-
def initialize(object, method, template_object, default_schedules = nil, options = {}, html_options = {})
106-
@default_schedules = default_schedules
107-
@choices = @choices.to_a if @choices.is_a?(Range)
108-
@method_name = method.to_s
109-
@object_name = object.to_s
110-
@html_options = recurring_select_html_options(html_options)
111-
add_default_name_and_id(@html_options)
112-
113-
super(object, method, template_object, options)
114-
end
93+
class RecurringSelectTag < ActionView::Helpers::Tags::Base
94+
include RecurringSelectHelper::FormOptionsHelper
95+
include SelectHTMLOptions
11596

116-
def render
117-
if Rails::VERSION::STRING >= '5.2'
118-
option_tags = add_options(recurring_options_for_select(value, @default_schedules, @options), @options, value)
119-
else
120-
option_tags = add_options(recurring_options_for_select(value(object), @default_schedules, @options), @options, value(object))
121-
end
122-
select_content_tag(option_tags, @options, @html_options)
123-
end
97+
def initialize(object, method, template_object, default_schedules = nil, options = {}, html_options = {})
98+
@default_schedules = default_schedules
99+
@choices = @choices.to_a if @choices.is_a?(Range)
100+
@method_name = method.to_s
101+
@object_name = object.to_s
102+
@html_options = recurring_select_html_options(html_options)
103+
add_default_name_and_id(@html_options)
104+
105+
super(object, method, template_object, options)
124106
end
125107

126-
else
127-
# === Rails 3
128-
class InstanceTag < ActionView::Helpers::InstanceTag
129-
include RecurringSelectHelper::FormOptionsHelper
130-
include SelectHTMLOptions
131-
132-
def to_recurring_select_tag(default_schedules, options, html_options)
133-
html_options = recurring_select_html_options(html_options)
134-
add_default_name_and_id(html_options)
135-
value = value(object)
136-
options = add_options(
137-
recurring_options_for_select(value, default_schedules, options),
138-
options, value
139-
)
140-
content_tag("select", options, html_options)
141-
end
108+
def render
109+
option_tags = add_options(recurring_options_for_select(value, @default_schedules, @options), @options, value)
110+
select_content_tag(option_tags, @options, @html_options)
142111
end
143112
end
144-
145-
146113
end

spec/gemfiles/Gemfile.rails-4.0.x

Lines changed: 0 additions & 10 deletions
This file was deleted.

spec/gemfiles/Gemfile.rails-4.1.x

Lines changed: 0 additions & 10 deletions
This file was deleted.

spec/gemfiles/Gemfile.rails-4.2.x

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)