Extract multi-line ternary out to private method
This commit is contained in:
parent
c192fbaa81
commit
f4d7f6e0f5
|
@ -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
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue