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:


571
572
573
# File 'lib/datastax_rails/relation/search_methods.rb', line 571

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

Instance Method Details

#equal_to(value) ⇒ Object

:nodoc:


575
576
577
578
579
580
581
582
583
# File 'lib/datastax_rails/relation/search_methods.rb', line 575

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

#greater_than(value) ⇒ Object

:nodoc:


585
586
587
588
589
590
591
592
593
# File 'lib/datastax_rails/relation/search_methods.rb', line 585

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

#less_than(value) ⇒ Object

:nodoc:


595
596
597
598
599
600
601
602
603
# File 'lib/datastax_rails/relation/search_methods.rb', line 595

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