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



282
283
284
285
286
287
288
289
290
# File 'lib/tanker.rb', line 282

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.



279
280
281
# File 'lib/tanker.rb', line 279

def index_name
  @index_name
end

#optionsObject

Returns the value of attribute options.



280
281
282
# File 'lib/tanker.rb', line 280

def options
  @options
end

Instance Method Details

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



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

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

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



300
301
302
# File 'lib/tanker.rb', line 300

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

#functions(&block) ⇒ Object



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

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

#indexObject



321
322
323
# File 'lib/tanker.rb', line 321

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

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



292
293
294
295
296
297
298
# File 'lib/tanker.rb', line 292

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

#variables(&block) ⇒ Object



311
312
313
314
# File 'lib/tanker.rb', line 311

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