Class: Ransack::Nodes::Attribute

Inherits:
Node
  • Object
show all
Includes:
Bindable
Defined in:
lib/ransack/nodes/attribute.rb

Instance Attribute Summary collapse

Attributes included from Bindable

#attr_name, #parent

Attributes inherited from Node

#context

Instance Method Summary collapse

Methods included from Bindable

#attr, #bound?, #klass, #ransacker, #reset_binding!

Methods inherited from Node

i18n_alias, i18n_word, #translate

Constructor Details

#initialize(context, name = nil) ⇒ Attribute

Returns a new instance of Attribute.



11
12
13
14
# File 'lib/ransack/nodes/attribute.rb', line 11

def initialize(context, name = nil)
  super(context)
  self.name = name unless name.blank?
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/ransack/nodes/attribute.rb', line 6

def name
  @name
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/ransack/nodes/attribute.rb', line 33

def eql?(other)
  self.class == other.class &&
  self.name == other.name
end

#hashObject



39
40
41
# File 'lib/ransack/nodes/attribute.rb', line 39

def hash
  self.name.hash
end

#inspectObject



47
48
49
# File 'lib/ransack/nodes/attribute.rb', line 47

def inspect
  "Attribute <#{name}>"
end

#persisted?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ransack/nodes/attribute.rb', line 43

def persisted?
  false
end

#typeObject



25
26
27
28
29
30
31
# File 'lib/ransack/nodes/attribute.rb', line 25

def type
  if ransacker
    return ransacker.type
  else
    context.type_for(self)
  end
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/ransack/nodes/attribute.rb', line 21

def valid?
  bound? && attr
end