Skip to content

Commit

Permalink
declared columns should at least return nil if attributes not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
rubysolo authored and Konstantin committed Mar 31, 2010
1 parent b5e7ed8 commit 35150d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sdb/active_sdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def domain
#
def [](attribute)
raw = @attributes[attribute.to_s]
self.class.column?(attribute) ? self.class.deserialize(attribute, raw.first) : raw
self.class.column?(attribute) && raw ? self.class.deserialize(attribute, raw.first) : raw
end

# Updates the attribute identified by +attribute+ with the specified +values+.
Expand Down Expand Up @@ -955,7 +955,7 @@ def method_missing(method_sym, *args)
setter = method_name[-1,1] == '='
method_name.chop! if setter

if @attributes.has_key? method_name
if @attributes.has_key?(method_name) || self.class.column?(method_name)
setter ? self[method_name] = args.first : self[method_name]
else
super
Expand Down

0 comments on commit 35150d5

Please sign in to comment.