Class: RansackCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/ransack_condition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) {|_self| ... } ⇒ RansackCondition

Returns a new instance of RansackCondition.

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
8
9
10
# File 'lib/ransack_condition.rb', line 4

def initialize(attributes={})
  @id = RansackQuery.generate_id
  @predicate = attributes[:predicate] || :eq
  @attribute = attributes[:attribute]
  @value = attributes[:value]
  yield self if block_given?
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



2
3
4
# File 'lib/ransack_condition.rb', line 2

def attribute
  @attribute
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/ransack_condition.rb', line 2

def id
  @id
end

#predicateObject

Returns the value of attribute predicate.



2
3
4
# File 'lib/ransack_condition.rb', line 2

def predicate
  @predicate
end

#valueObject

Returns the value of attribute value.



2
3
4
# File 'lib/ransack_condition.rb', line 2

def value
  @value
end

Instance Method Details

#ransackifyObject



12
13
14
15
16
17
18
19
20
# File 'lib/ransack_condition.rb', line 12

def ransackify
  {
      @id => {
          'a' => build_ransack_array(@attribute, 'name'),
          'p' => @predicate.to_s,
          'v' => build_ransack_array(@value, 'value')
      }
  }
end

#to_conditionObject



22
23
24
# File 'lib/ransack_condition.rb', line 22

def to_condition
  self
end