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.



317
318
319
320
321
322
323
324
325
# File 'lib/tanker.rb', line 317

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

Instance Attribute Details

#index_nameObject

Returns the value of attribute index_name.



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

def index_name
  @index_name
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#categories(field = nil, options = {}, &block) ⇒ Object



339
340
341
342
343
344
# File 'lib/tanker.rb', line 339

def categories(field = nil, options = {}, &block)
  if field
    @categories  << [field, block]
  end
  @categories
end

#category(field = nil, options = {}, &block) ⇒ Object



335
336
337
# File 'lib/tanker.rb', line 335

def category(field = nil, options = {}, &block)
  categories field, options, &block
end

#functions(&block) ⇒ Object



351
352
353
354
# File 'lib/tanker.rb', line 351

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

#indexObject



356
357
358
# File 'lib/tanker.rb', line 356

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

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



327
328
329
330
331
332
333
# File 'lib/tanker.rb', line 327

def indexes(field = nil, options = {}, &block)
  if field
    @indexes     << [field, block]
    @categories  << [field, block] if options[:category]
  end
  @indexes
end

#variables(&block) ⇒ Object



346
347
348
349
# File 'lib/tanker.rb', line 346

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