Skip to content

Commit 03c8b87

Browse files
committed
Extract method
1 parent 35437bd commit 03c8b87

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/ajax-datatables-rails/datatable/simple_order.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ def column
2020
end
2121

2222
def direction
23-
DIRECTIONS.find { |dir| dir == @options[:dir].upcase } || 'ASC'
23+
DIRECTIONS.find { |dir| dir == column_direction } || 'ASC'
2424
end
2525

2626
private
2727

2828
def column_index
2929
@options[:column]
3030
end
31+
32+
def column_direction
33+
@options[:dir].upcase
34+
end
35+
3136
end
3237
end
3338
end

spec/ajax-datatables-rails/datatable/simple_order_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe AjaxDatatablesRails::Datatable::SimpleOrder do
44

5-
let(:options) { ActiveSupport::HashWithIndifferentAccess.new({'column'=>'1', 'dir'=>'desc'}) }
5+
let(:options) { ActiveSupport::HashWithIndifferentAccess.new({'column' => '1', 'dir' => 'desc'}) }
66
let(:simple_order) { AjaxDatatablesRails::Datatable::SimpleOrder.new(nil, options) }
77

88
describe 'option methods' do

0 commit comments

Comments
 (0)