Class: Tanker::ModelConfig

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index_name, options = {}, block) ⇒ ModelConfig

Returns a new instance of ModelConfig.



295
296
297
298
299
300
301
302
# File 'lib/tanker.rb', line 295

def initialize(index_name, options = {}, block)
  @index_name = index_name
  @options    = options
  @indexes    = []
  @variables  = []
  @functions  = {}
  instance_exec &block
end

Instance Attribute Details

#index_nameObject

Returns the value of attribute index_name.



292
293
294
# File 'lib/tanker.rb', line 292

def index_name
  @index_name
end

#optionsObject

Returns the value of attribute options.



293
294
295
# File 'lib/tanker.rb', line 293

def options
  @options
end

Instance Method Details

#functions(&block) ⇒ Object



314
315
316
317
# File 'lib/tanker.rb', line 314

def functions(&block)
  @functions = block.call if block
  @functions
end

#indexObject



319
320
321
# File 'lib/tanker.rb', line 319

def index
  @index ||= Tanker.api.get_index(index_name)
end

#indexes(field = nil, &block) ⇒ Object



304
305
306
307
# File 'lib/tanker.rb', line 304

def indexes(field = nil, &block)
  @indexes << [field, block] if field
  @indexes
end

#variables(&block) ⇒ Object



309
310
311
312
# File 'lib/tanker.rb', line 309

def variables(&block)
  @variables << block if block
  @variables
end