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.



272
273
274
275
276
277
278
279
# File 'lib/tanker.rb', line 272

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.



269
270
271
# File 'lib/tanker.rb', line 269

def index_name
  @index_name
end

#optionsObject

Returns the value of attribute options.



270
271
272
# File 'lib/tanker.rb', line 270

def options
  @options
end

Instance Method Details

#functions(&block) ⇒ Object



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

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

#indexObject



296
297
298
# File 'lib/tanker.rb', line 296

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

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



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

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

#variables(&block) ⇒ Object



286
287
288
289
# File 'lib/tanker.rb', line 286

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