Skip to content

Commit

Permalink
Minor amends, fixed becomes, removed unneeded arg to define_with_scrooge
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsykes committed Mar 10, 2009
1 parent 76a27ff commit 2cf1fee
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/scrooge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ def define_read_method(symbol, attr_name, column)
if cache_attribute?(attr_name)
access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})"
end
define_with_scrooge(symbol, attr_name, access_code, "")
define_with_scrooge(symbol, attr_name, access_code)
end

# Graceful missing attribute wrapper.
#
def define_with_scrooge(symbol, attr_name, access_code, args)
def define_with_scrooge(symbol, attr_name, access_code)
method_def = <<-EOV
def #{symbol}#{args}
def #{symbol}
begin
#{access_code}
rescue ActiveRecord::MissingAttributeError => e
Expand Down Expand Up @@ -316,12 +316,14 @@ def becomes(klass)
became.instance_variable_set("@attributes", @attributes)
became.instance_variable_set("@attributes_cache", @attributes_cache)
became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@is_scrooged", @is_scrooged)
became.instance_variable_set("@scrooge_fully_loaded", @scrooge_fully_loaded)
became.instance_variable_set("@scrooge_own_callsite_set", @scrooge_own_callsite_set)
became.instance_variable_set("@scrooge_callsite_set", @scrooge_callsite_set)
if @is_scrooged
became.instance_variable_set("@is_scrooged", true)
became.instance_variable_set("@scrooge_fully_loaded", @scrooge_fully_loaded)
became.instance_variable_set("@scrooge_own_callsite_set", @scrooge_own_callsite_set)
became.instance_variable_set("@scrooge_callsite_signature", @scrooge_callsite_signature)
end
end
end
end

def scrooge_dump_flag_this
Thread.current[:scrooge_dumping_objects] ||= []
Expand Down

0 comments on commit 2cf1fee

Please sign in to comment.