Sha256: 3a731c85795af894f81b2f7de1306dea97973f8a3a267b3b7e523e2e734fd6aa

Contents?: true

Size: 663 Bytes

Versions: 4

Compression:

Stored size: 663 Bytes

Contents

class Dynomite::Item::Query::Relation
  class WhereField
    attr_reader :full_field, :value, :index
    def initialize(full_field, value, index)
      @full_field, @value, @index = full_field.to_s, value, index
    end

    def field
      @full_field.split('.').first
    end

    def operator
      if raw_operator
        not? ? raw_operator[4..-1] : raw_operator
      end
    end

    def not?
      raw_operator.match(/^not_/) if raw_operator
    end

    def raw_operator
      _, operator = @full_field.split('.')
      operator.downcase if operator
    end

    # Example: price_1, price_2
    def reference
      "#{field}_#{@index}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynomite-2.0.3 lib/dynomite/item/query/relation/where_field.rb
dynomite-2.0.2 lib/dynomite/item/query/relation/where_field.rb
dynomite-2.0.1 lib/dynomite/item/query/relation/where_field.rb
dynomite-2.0.0 lib/dynomite/item/query/relation/where_field.rb