Module: Tanker::InstanceMethods
- Defined in:
- lib/tanker.rb
Overview
these are the instance methods included
Instance Method Summary collapse
-
#delete_tank_indexes ⇒ Object
delete instance from index tank.
-
#it_doc_id ⇒ Object
create a unique index based on the model name and unique id.
- #tanker_config ⇒ Object
- #tanker_index_data ⇒ Object
- #tanker_index_options ⇒ Object
- #tanker_indexes ⇒ Object
- #tanker_variables ⇒ Object
-
#update_tank_indexes ⇒ Object
update a create instance from index tank.
Instance Method Details
#delete_tank_indexes ⇒ Object
delete instance from index tank
249 250 251 |
# File 'lib/tanker.rb', line 249 def delete_tank_indexes tanker_config.index.delete_document(it_doc_id) end |
#it_doc_id ⇒ Object
create a unique index based on the model name and unique id
284 285 286 |
# File 'lib/tanker.rb', line 284 def it_doc_id self.class.name + ' ' + self.id.to_s end |
#tanker_config ⇒ Object
229 230 231 |
# File 'lib/tanker.rb', line 229 def tanker_config self.class.tanker_config || raise(NotConfigured, "Please configure Tanker for #{self.class.inspect} with the 'tankit' block") end |
#tanker_index_data ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/tanker.rb', line 253 def tanker_index_data data = {} # attempt to autodetect timestamp if respond_to?(:created_at) data[:timestamp] = created_at.to_i end tanker_indexes.each do |field, block| val = block ? instance_exec(&block) : send(field) val = val.join(' ') if Array === val data[field.to_sym] = val.to_s unless val.nil? end data[:__any] = data.values.sort_by{|v| v.to_s}.join " . " data[:__type] = self.class.name data end |
#tanker_index_options ⇒ Object
273 274 275 276 277 278 279 280 281 |
# File 'lib/tanker.rb', line 273 def = {} if tanker_variables [:variables] = instance_exec(&tanker_variables) end end |
#tanker_indexes ⇒ Object
233 234 235 |
# File 'lib/tanker.rb', line 233 def tanker_indexes tanker_config.indexes end |
#tanker_variables ⇒ Object
237 238 239 |
# File 'lib/tanker.rb', line 237 def tanker_variables tanker_config.variables end |
#update_tank_indexes ⇒ Object
update a create instance from index tank
242 243 244 245 246 |
# File 'lib/tanker.rb', line 242 def update_tank_indexes tanker_config.index.add_document( it_doc_id, tanker_index_data, ) end |