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
|
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
|
Loading…
Reference in New Issue