Class: Hayabusa::Models::Log_data_value

Inherits:
Datarow
  • Object
show all
Defined in:
lib/models/log_data_value.rb

Class Method Summary collapse

Methods inherited from Datarow

#[], #[]=, #__object_unique_id__, autodelete_data, autozero_data, classname, classname=, columns_sqlhelper_args, #data, db, #db, #deleted?, #deleted_from_db?, depending_data, #destroy, #each, has_many, has_one, has_translation, #html, #id, #initialize, initialized?, #is_knj?, is_nullstamp?, joined_tables, #key?, list, list_helper, load_columns, #name, #name_html, #ob, ob, #reload, required_data, #should_reload, table, #table, table=, #to_hash, translations, #update, #url, #url_edit

Constructor Details

This class inherits a constructor from Hayabusa::Datarow

Class Method Details

.force(d, value) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/models/log_data_value.rb', line 2

def self.force(d, value)
  value_obj = d.ob.get_by(:Log_data_value, {
    "value" => value.to_s
  })

  if !value_obj
    value_obj = d.ob.add(:Log_data_value, {"value" => value})
  end

  return value_obj
end

.force_id(d, value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/models/log_data_value.rb', line 14

def self.force_id(d, value)
  d.db.select(:Log_data_value, {"value" => value}) do |d_val|
    return d_val[:id].to_i if d_val[:value].to_s == value.to_s #MySQL doesnt take upper/lower-case into consideration because value is a text-column... lame! - knj
  end

  return d.db.insert(:Log_data_value, {:value => value}, {:return_id => true}).to_i
end