Extract multi-line ternary out to private method

This commit is contained in:
Jon Atack 2014-11-21 20:16:29 +01:00
parent c192fbaa81
commit f4d7f6e0f5
1 changed files with 12 additions and 4 deletions

View File

@ -5,9 +5,7 @@ module Ransack
attr_accessor :parent, :attr_name attr_accessor :parent, :attr_name
def attr def attr
@attr ||= ransacker ? @attr ||= get_arel_attribute
ransacker.attr_from(self) :
context.table_for(parent)[attr_name]
end end
alias :arel_attribute :attr alias :arel_attribute :attr
@ -27,6 +25,16 @@ module Ransack
@parent = @attr_name = @attr = @klass = nil @parent = @attr_name = @attr = @klass = nil
end end
private
def get_arel_attribute
if ransacker
ransacker.attr_from(self)
else
context.table_for(parent)[attr_name]
end
end
end end
end end
end end