mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
30 lines
No EOL
565 B
Ruby
30 lines
No EOL
565 B
Ruby
module Ransack
|
|
module Nodes
|
|
module Bindable
|
|
|
|
attr_accessor :parent, :attr_name
|
|
|
|
def attr
|
|
@attr ||= ransacker ? ransacker.attr_from(self) : context.table_for(parent)[attr_name]
|
|
end
|
|
alias :arel_attribute :attr
|
|
|
|
def ransacker
|
|
klass._ransackers[attr_name]
|
|
end
|
|
|
|
def klass
|
|
@klass ||= context.klassify(parent)
|
|
end
|
|
|
|
def bound?
|
|
attr_name.present? && parent.present?
|
|
end
|
|
|
|
def reset_binding!
|
|
@parent = @attr_name = @attr = @klass = nil
|
|
end
|
|
|
|
end
|
|
end
|
|
end |