Skip to content
Browse files

Debug dinamic _str methods.

  • Loading branch information...
1 parent 9ded04c commit 1165a557b4ad9ff41cc86856059830ea03a40a7b @levmatta-umanni levmatta-umanni committed Oct 13, 2011
Showing with 3 additions and 3 deletions.
  1. +2 −2 lib/cassandra-model/base.rb
  2. +1 −1 lib/cassandra-model/version.rb
View
4 lib/cassandra-model/base.rb
@@ -37,7 +37,7 @@ def #{name}
end
if @key_type.downcase == 'timeuuid' or @key_type.downcase == 'time_uuid'
def #{name}_str
- SimpleUUID::UUID.new(@key).to_guid
+ (@key.nil? or @key.size == 0) ? nil : SimpleUUID::UUID.new(@key).to_guid
end
end
EVAL
@@ -48,7 +48,7 @@ def column(name, type = :string)
class_eval "def #{name}; #{type.capitalize}Type.load(@attributes['#{name}']); end"
class_eval "def #{name}=(value); @attributes['#{name}'] = #{type.capitalize}Type.dump(value); end"
if type.downcase == 'timeuuid' or type.downcase == 'time_uuid'
- class_eval "def #{name}_str; #{type.capitalize}Type.load(@attributes['#{name}']).to_guid; end"
+ class_eval "def #{name}_str; (@attributes['#{name}'].nil? or @attributes['#{name}'].size == 0) ? nil : #{type.capitalize}Type.load(@attributes['#{name}']).to_guid; end"
end
end
View
2 lib/cassandra-model/version.rb
@@ -1,3 +1,3 @@
class CassandraModel
- VERSION = '0.1.13'
+ VERSION = '0.1.14'
end

0 comments on commit 1165a55

Please sign in to comment.
Something went wrong with that request. Please try again.