Support SimpleUUID::UUID instances as well. #35

Merged
merged 1 commit into from Nov 8, 2012

2 participants

@jnunemaker

Since CassandraCQL::UUID just inherits from it, we might as well support the whole family. I've already had a few times where I tried to insert SimpleUUID::UUID's and it didn't work, which confused me.

@jnunemaker jnunemaker Support SimpleUUID::UUID instances as well.
Since CassandraCQL::UUID just inherits from it, we might as well
support the whole family. I've already had a few times where I tried to
insert SimpleUUID::UUID's and it didn't work, which confused me.
06d2a2a
@jnunemaker jnunemaker commented on the diff Nov 8, 2012
lib/cassandra-cql/statement.rb
@@ -90,7 +90,7 @@ def self.cast_to_cql(obj)
obj.strftime('%Y-%m-%d')
elsif obj.kind_of?(Time)
(obj.to_f * 1000).to_i
- elsif obj.kind_of?(UUID)
+ elsif obj.kind_of?(SimpleUUID::UUID)

I would actually prefer to just do obj.respond_to?(:to_guid), but I stuck with the current conventions.

@kreynolds
Owner

The rationale was that there could eventually be different UUID backends, one written in C, a networked canonical service of some sort, etc and I didn't want to directly use a single back-end but instead use an abstraction layer. That said, the mechanism for switching back ends doesn't exist yet so if this makes your life easier, I can dig it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kreynolds kreynolds merged commit 012bd70 into kreynolds:master Nov 8, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment