Class: DatastaxRails::SearchMethods::WhereProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/datastax_rails/relation/search_methods.rb

Overview

WhereProxy objects act as a placeholder for queries in which #where does not include a value. In this case, #where must be chained with #greater_than, #less_than, or #equal_to to return a new relation.

Instance Method Summary collapse

Constructor Details

#initialize(relation, attribute, invert = false) ⇒ WhereProxy

:nodoc:



566
567
568
# File 'lib/datastax_rails/relation/search_methods.rb', line 566

def initialize(relation, attribute, invert = false) #:nodoc:
  @relation, @attribute, @invert = relation, attribute, invert
end

Instance Method Details

#equal_to(value) ⇒ Object

:nodoc:



570
571
572
573
574
575
576
577
578
# File 'lib/datastax_rails/relation/search_methods.rb', line 570

def equal_to(value) #:nodoc:
  @relation.clone.tap do |r|
    if @invert
      r.where_not_values << { @attribute => r.solr_format(@attribute, value) }
    else
      r.where_values << { @attribute => r.solr_format(@attribute, value) }
    end
  end
end

#greater_than(value) ⇒ Object

:nodoc:



580
581
582
583
584
585
586
587
588
# File 'lib/datastax_rails/relation/search_methods.rb', line 580

def greater_than(value) #:nodoc:
  @relation.clone.tap do |r|
    if @invert
      r.less_than_values << { @attribute => r.solr_format(@attribute, value) }
    else
      r.greater_than_values << { @attribute => r.solr_format(@attribute, value) }
    end
  end
end

#less_than(value) ⇒ Object

:nodoc:



590
591
592
593
594
595
596
597
598
# File 'lib/datastax_rails/relation/search_methods.rb', line 590

def less_than(value) #:nodoc:
  @relation.clone.tap do |r|
    if @invert
      r.greater_than_values << { @attribute => r.solr_format(@attribute, value) }
    else
      r.less_than_values << { @attribute => r.solr_format(@attribute, value) }
    end
  end
end