Class: Tanker::ModelConfig
- Inherits:
-
Object
- Object
- Tanker::ModelConfig
- Defined in:
- lib/tanker.rb
Instance Attribute Summary collapse
-
#index_name ⇒ Object
Returns the value of attribute index_name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #categories(field = nil, options = {}, &block) ⇒ Object
- #category(field = nil, options = {}, &block) ⇒ Object
- #functions(&block) ⇒ Object
- #index ⇒ Object
- #indexes(field = nil, options = {}, &block) ⇒ Object
-
#initialize(index_name, options, block) ⇒ ModelConfig
constructor
A new instance of ModelConfig.
- #variables(&block) ⇒ Object
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, , block) @index_name = index_name @options = @indexes = [] @categories = [] @variables = [] @functions = {} instance_exec &block end |
Instance Attribute Details
#index_name ⇒ Object
Returns the value of attribute index_name.
314 315 316 |
# File 'lib/tanker.rb', line 314 def index_name @index_name end |
#options ⇒ Object
Returns the value of attribute options.
315 316 317 |
# File 'lib/tanker.rb', line 315 def @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, = {}, &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, = {}, &block) categories field, , &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 |
#index ⇒ Object
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, = {}, &block) if field @indexes << [field, block] @categories << [field, block] if [: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 |