Class: Jabara::MySQL::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/jabara/mysql/output.rb

Instance Method Summary collapse

Constructor Details

#initialize(null_value: 'null') ⇒ Output

Returns a new instance of Output.



7
8
9
# File 'lib/jabara/mysql/output.rb', line 7

def initialize(null_value:'null')
  @null_value = null_value
end

Instance Method Details

#encode(object_repr) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/jabara/mysql/output.rb', line 11

def encode(object_repr)
  table_name = ::Jabara.object_type(object_repr)
  mysql_value_hash = {}
  ::Jabara.data(object_repr).each do |key, repr|
    mysql_value_hash[key] = mysql_value(repr)
  end
  build_insert_query(table_name, mysql_value_hash)
end