class RediSearch::Create
Constants
- OPTION_MAPPER
Attributes
index[R]
options[R]
schema[R]
Public Class Methods
new(index, schema, options)
click to toggle source
# File lib/redi_search/create.rb, line 13 def initialize(index, schema, options) @index = index @schema = schema @options = options end
Public Instance Methods
call()
click to toggle source
# File lib/redi_search/create.rb, line 23 def call call! rescue Redis::CommandError false end
call!()
click to toggle source
# File lib/redi_search/create.rb, line 19 def call! RediSearch.client.call!(*command).ok? end
Private Instance Methods
command()
click to toggle source
# File lib/redi_search/create.rb, line 33 def command ["CREATE", index.name, "ON", "HASH", "PREFIX", 1, index.name, *extract_options.compact, "SCHEMA", schema.to_a] end
extract_options()
click to toggle source
# File lib/redi_search/create.rb, line 38 def extract_options options.map do |clause, switch| next unless OPTION_MAPPER.key?(clause.to_sym) && switch OPTION_MAPPER[clause.to_sym] end + temporary_option end
temporary_option()
click to toggle source
# File lib/redi_search/create.rb, line 46 def temporary_option return [] unless options[:temporary] ["TEMPORARY", options[:temporary]] end