From f4d7f6e0f547aae5f92f739214115dffb296926b Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Fri, 21 Nov 2014 20:16:29 +0100 Subject: [PATCH] Extract multi-line ternary out to private method --- lib/ransack/nodes/bindable.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/ransack/nodes/bindable.rb b/lib/ransack/nodes/bindable.rb index ed18e65..b80d8ae 100644 --- a/lib/ransack/nodes/bindable.rb +++ b/lib/ransack/nodes/bindable.rb @@ -5,9 +5,7 @@ module Ransack attr_accessor :parent, :attr_name def attr - @attr ||= ransacker ? - ransacker.attr_from(self) : - context.table_for(parent)[attr_name] + @attr ||= get_arel_attribute end alias :arel_attribute :attr @@ -27,6 +25,16 @@ module Ransack @parent = @attr_name = @attr = @klass = nil end + private + + def get_arel_attribute + if ransacker + ransacker.attr_from(self) + else + context.table_for(parent)[attr_name] + end + end + end end -end \ No newline at end of file +end