Module: Ransack::Nodes::Bindable

Included in:
Attribute, Sort
Defined in:
lib/ransack/nodes/bindable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attr_nameObject

Returns the value of attribute attr_name.



5
6
7
# File 'lib/ransack/nodes/bindable.rb', line 5

def attr_name
  @attr_name
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/ransack/nodes/bindable.rb', line 5

def parent
  @parent
end

Instance Method Details

#attrObject Also known as: arel_attribute



7
8
9
10
11
# File 'lib/ransack/nodes/bindable.rb', line 7

def attr
  @attr ||= ransacker ?
    ransacker.attr_from(self) :
    context.table_for(parent)[attr_name]
end

#bound?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ransack/nodes/bindable.rb', line 22

def bound?
  attr_name.present? && parent.present?
end

#klassObject



18
19
20
# File 'lib/ransack/nodes/bindable.rb', line 18

def klass
  @klass ||= context.klassify(parent)
end

#ransackerObject



14
15
16
# File 'lib/ransack/nodes/bindable.rb', line 14

def ransacker
  klass._ransackers[attr_name]
end

#reset_binding!Object



26
27
28
# File 'lib/ransack/nodes/bindable.rb', line 26

def reset_binding!
  @parent = @attr_name = @attr = @klass = nil
end