breaks after ever change immobility - code hopelessly entangled, you can’t reuse viscous - behaving badly is the most attractive alternative Tuesday, November 6, 12
:about def initialize(name="", url="", about="") @name = name @url = url @about = about end end class Database @@db ||= SQLite3::Database.new('jobs.db') @@db.results_as_hash = true def insert_employer @@db.execute("INSERT INTO employers (name, url, about) VALUES (?, ?, ?)", [@name, @url, @about]) end end Tuesday, November 6, 12
url="", about="") @name = name @url = url @about = about end end def save Database.new.insert_record(table, attribute_names, attributes) end Tuesday, November 6, 12
url="", about="") @name = name @url = url @about = about end end def self.table @@table ||= "employers" end def save Database.new.insert_record(table, attribute_names, attributes) end Tuesday, November 6, 12
url="", about="") @name = name @url = url @about = about end end def self.table @@table ||= "employers" end def save Database.new.insert_record( table, attribute_names, attributes) end Tuesday, November 6, 12
url="", about="") @name = name @url = url @about = about end end def self.table @@table ||= "employers" end def save Database.new.insert_record( table, attribute_names, attributes) end self.class. Tuesday, November 6, 12
url="", about="") @name = name @url = url @about = about end end def self.table @@table ||= "employers" end def save Database.new.insert_record( table, attribute_names, attributes) end self.class. Tuesday, November 6, 12
self.table @@table ||= "employers" end def save attribute_names = self.instance_variables.map do |var| var.to_s.sub("@", "") end attributes = attribute_names.map do |att_name| self.send(att_name.to_sym) end Database.new.insert_record(self.class.table, attribute_names, attributes) end Tuesday, November 6, 12
"employers" end def save Database.new.insert_record(self.class.table, self.attribute_names, self.attributes) end def attribute_names self.instance_variables.map do |var| var.to_s.sub("@", "") end end def attributes attribute_names.map do |att_name| self.send(att_name.to_sym) end end end Tuesday, November 6, 12
:url, :about def initialize(name="", url="", about="") @name = name @url = url @about = about end def self.table @@table ||= "employers" end def save Database.new.insert_record(self.class.table, self.attribute_names, self.attributes) end end Tuesday, November 6, 12
Attributable attr_accessor :name, :url, :about def initialize(name="", url="", about="") @name = name @url = url @about = about end def self.table @@table ||= "employers" end def save Database.new.insert_record(self.class.table, self.attribute_names, self.attributes) end end Tuesday, November 6, 12
attr_accessor :name, :url, :about def initialize(name="", url="", about="") @name = name @url = url @about = about end def self.table @@table ||= "employers" end def save Database.new.insert_record(self.class.table, self.attribute_names, self.attributes) end end Tuesday, November 6, 12
var.to_s.sub("@", "") end end def attributes attribute_names.map do |att_name| self.send(att_name.to_sym) end end end module Persistable def save Database.new.insert_record(self.class.table, self.attribute_names, self.attributes) end end Tuesday, November 6, 12
Persistable attr_accessor :name, :url, :about def initialize(name="", url="", about="") @name = name @url = url @about = about end def self.table @@table ||= "employers" end end Tuesday, November 6, 12
def initialize(name="", url="", about="") @name = name @url = url @about = about end end def initialize(args={}) args.each do |key, value| self.send("#{key.to_sym}=", value) end end Same As Tuesday, November 6, 12
Attributable, Persistable attr_accessor :name, :url, :about def initialize(args = {}) args.each do |key, value| self.send("#{key.to_sym}=", value) end end def self.table @@table ||= "employers" end end Tuesday, November 6, 12