Class: Neo4j::Rails::Validations::FulltextMatchValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/rails/validations/uniqueness.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) downcase(value)



65
66
67
# File 'lib/neo4j/rails/validations/uniqueness.rb', line 65

def self.downcase(value)
  value.nil? ? value : value.strip.downcase
end

+ (Object) index_type



52
53
54
# File 'lib/neo4j/rails/validations/uniqueness.rb', line 52

def self.index_type
  :fulltext
end

+ (Object) match(rec, attribute, value)



61
62
63
# File 'lib/neo4j/rails/validations/uniqueness.rb', line 61

def self.match(rec,attribute,value)
  downcase(rec[attribute]) == downcase(value)
end

+ (Object) query(model, attribute, value)



56
57
58
59
# File 'lib/neo4j/rails/validations/uniqueness.rb', line 56

def self.query(model,attribute,value)
  value = value.gsub("\"", "\\\"") if !value.blank?
  value.blank? ? model.all("*:* -#{attribute}:[* TO *]", :type => :fulltext) : model.all("#{attribute}: \"#{value}\"", :type => :fulltext)
end