class ProconBypassMan::Web::BaseModel
Public Class Methods
column_names()
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 23 def self.column_names raise "need to define column_names" if not defined?(@@column_names) @@column_names end
column_names=(c)
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 19 def self.column_names=(c) @@column_names = c end
count()
click to toggle source
@return [Numric]
# File lib/procon_bypass_man/web/models/base_model.rb, line 11 def self.count db.execute("select count(*) from #{table_name}").first.first end
db()
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 15 def self.db ProconBypassMan::Web::Db.db end
new(row)
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 4 def initialize(row) @@column_names.each.with_index(0) do |name, index| self.public_send("#{name}=", row[index]) end end
table_name()
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 28 def self.table_name raise "need to define column_names" if not defined?(@@table_name) @@table_name end
table_name=(value)
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 33 def self.table_name=(value) @@table_name = value end
Public Instance Methods
table_name()
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 37 def table_name self.class.table_name end
update!(attributes)
click to toggle source
# File lib/procon_bypass_man/web/models/base_model.rb, line 41 def update!(attributes) c = attributes.map {|key, _value| "'#{key}' = ?" }.join(", ") self.class.db.execute("update #{table_name} set #{c}", attributes.map {|_key, value| value }) end