Class: RansackCondition
- Inherits:
-
Object
- Object
- RansackCondition
- Defined in:
- lib/ransack_condition.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#id ⇒ Object
Returns the value of attribute id.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(attributes = {}) {|_self| ... } ⇒ RansackCondition
constructor
A new instance of RansackCondition.
- #ransackify ⇒ Object
- #to_condition ⇒ Object
Constructor Details
#initialize(attributes = {}) {|_self| ... } ⇒ RansackCondition
Returns a new instance of RansackCondition.
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
#attribute ⇒ Object
Returns the value of attribute attribute.
2 3 4 |
# File 'lib/ransack_condition.rb', line 2 def attribute @attribute end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/ransack_condition.rb', line 2 def id @id end |
#predicate ⇒ Object
Returns the value of attribute predicate.
2 3 4 |
# File 'lib/ransack_condition.rb', line 2 def predicate @predicate end |
#value ⇒ Object
Returns the value of attribute value.
2 3 4 |
# File 'lib/ransack_condition.rb', line 2 def value @value end |
Instance Method Details
#ransackify ⇒ Object
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_condition ⇒ Object
22 23 24 |
# File 'lib/ransack_condition.rb', line 22 def to_condition self end |