November 18
Using Mocha in Development is Handy
I wanted to manually run a script, that was going to be setup as a cronjob. This script looked for order objects in the database, having a delivery_date in the next 24 hours.
I wanted to test this script, and the orders that it pulled back for processing, however, almost all of the delivery_dates we days in advance, so I just used mocha…
require 'mocha'
Time.stubs(:now).returns("11/20/2008 16:00:00".to_time)
That way I can just run the script, and mocha will make my call to Time.now thing that it is indeed November 20th 2008 at 4pm.
November 16
Morgen
I am starting to change shape
November 11
The Essence of ARBWOT
module ActiveRecord
class BaseWithoutTable < Base
self.abstract_class = true
def create_or_update
errors.empty?
end
class << self
def columns()
@columns ||= []
end
def column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
reset_column_information
end
# Do not reset @columns
def reset_column_information
generated_methods.each { |name| undef_method(name) }
@column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil
end
end
end
end
Going to go down in the water,
fill my mouth up full of sand.
I’ll be waiting still impatient with my dead imagination while you’re with some other man.
October 20
Create getters and setters from a ActiveRecord serialized db column
class Blog < ActiveRecord::Base
serialize :metadata
class << self
def attr_serialized_on(column, *attributes)
attributes.each do |a|
class_eval do
define_method(a) { meta(a) }
define_method(a.to_s + "=(value)") { metadata[a] = value }
end
end
end
end
def meta(key)
metadata[key]
end
attr_serialized_on(:metadata, :title, :subtitle, :background, :foreground)
end
Fingerapp.com | Rails Rumble 08
With the help of my good friends, I’ve created http://fingerapp.com for railsrumble, it’s not perfect, needs work, but I’m proud of what we were able to build in 48 hours. Thanks Tony, Chris, and Owen.
Hey dean! James Dean wore jeans, dean!
- Steve D