Class: GroongaClientModel::LoadValueGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga_client_model/load_value_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ LoadValueGenerator

Returns a new instance of LoadValueGenerator.



21
22
23
# File 'lib/groonga_client_model/load_value_generator.rb', line 21

def initialize(record)
  @record = record
end

Instance Method Details

#generateObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/groonga_client_model/load_value_generator.rb', line 25

def generate
  load_value = {}
  @record.attributes.each do |name, value|
    next if value.nil?
    load_value[name] = format_value(value)
  end
  if load_value.key?("_id") and load_value.key?("_key")
    load_value.delete("_id")
  end
  load_value
end