Skip to content
This repository
Browse code

Rails 3.1 full compatible

  • Loading branch information...
commit 230d21ebf593427926d2d0961a4e0af1ce8cc5ec 1 parent 70f8c4e
Arkadiy Zabazhanov pyromaniac authored
11 Gemfile
@@ -2,3 +2,14 @@ source "http://rubygems.org"
2 2
3 3 # Specify your gem's dependencies in activeuuid.gemspec
4 4 gemspec
  5 +
  6 +case version = ENV['ACTIVERECORD_VERSION'] || '~> 3.2'
  7 +when /master/
  8 + gem "activerecord", :github => "rails/rails"
  9 +when /3-1-stable/
  10 + gem "activerecord", :github => "rails/rails", :branch => "3-1-stable"
  11 +when /3-2-stable/
  12 + gem "activerecord", :github => "rails/rails", :branch => "3-2-stable"
  13 +else
  14 + gem "activerecord", version
  15 +end
2  lib/activeuuid/patches.rb
@@ -52,7 +52,7 @@ def type_cast_with_visiting(value, column = nil)
52 52 def self.apply!
53 53 ActiveRecord::ConnectionAdapters::Table.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::Table
54 54 ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::TableDefinition
55   - ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
  55 + ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
56 56 ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
57 57 ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, PostgreSQLQuoting if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
58 58 end
7 lib/activeuuid/uuid.rb
... ... @@ -1,8 +1,8 @@
1 1 require 'uuidtools'
2 2
  3 +# monkey-patch Friendly::UUID to serialize UUIDs
3 4 module UUIDTools
4 5 class UUID
5   - # monkey-patch Friendly::UUID to serialize UUIDs to MySQL
6 6 alias_method :id, :raw
7 7
8 8 def quoted_id
@@ -17,6 +17,9 @@ def as_json(options = nil)
17 17 def to_param
18 18 hexdigest.upcase
19 19 end
  20 +
  21 + # duck typing activerecord 3.1 dirty hack )
  22 + def gsub *; self; end
20 23 end
21 24 end
22 25
@@ -75,7 +78,7 @@ def dump(uuid)
75 78 private
76 79
77 80 def parse_string str
78   - return nil if str.blank?
  81 + return nil if str.length == 0
79 82 if str.length == 36
80 83 UUIDTools::UUID.parse str
81 84 elsif str.length == 32

0 comments on commit 230d21e

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