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:



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

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

Instance Method Details

#equal_to(value) ⇒ Object

:nodoc:



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

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:



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

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:



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

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