Class: RediSearch::AddField

Inherits:
Object
  • Object
show all
Defined in:
lib/redi_search/add_field.rb

Instance Method Summary collapse

Constructor Details

#initialize(index, name, type, **options, &block) ⇒ AddField

Returns a new instance of AddField.



5
6
7
8
9
10
11
# File 'lib/redi_search/add_field.rb', line 5

def initialize(index, name, type, **options, &block)
  @index   = index
  @name    = name
  @type    = type
  @options = options
  @block   = block
end

Instance Method Details

#callObject



19
20
21
22
23
# File 'lib/redi_search/add_field.rb', line 19

def call
  call!
rescue Redis::CommandError
  false
end

#call!Object



13
14
15
16
17
# File 'lib/redi_search/add_field.rb', line 13

def call!
  field = index.schema.add_field(name, type, **options, &block)

  RediSearch.client.call!("ALTER", index.name, "SCHEMA", "ADD", *field).ok?
end