Skip to content

Commit

Permalink
Merge pull request #1 from idibon/support-ar-40
Browse files Browse the repository at this point in the history
Add support for ActiveRecord 4.x
  • Loading branch information
brendandc committed Feb 24, 2014
2 parents 77265c3 + a0c478d commit 24fee78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/activeuuid/patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Migrations
def uuid(*column_names)
options = column_names.extract_options!
column_names.each do |name|
type = @base.adapter_name.downcase == 'postgresql' ? 'uuid' : 'binary(16)'
type = ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql' ? 'uuid' : 'binary(16)'
column(name, "#{type}#{' PRIMARY KEY' if options.delete(:primary_key)}", options)
end
end
Expand Down
18 changes: 9 additions & 9 deletions lib/activeuuid/uuid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ def self.parse_string(str)
module Arel
module Visitors
class DepthFirst < Arel::Visitors::Visitor
def visit_UUIDTools_UUID(o)
o.quoted_id
def visit_UUIDTools_UUID(object, attribute)
object.quoted_id
end
end

class MySQL < Arel::Visitors::ToSql
def visit_UUIDTools_UUID(o)
o.quoted_id
def visit_UUIDTools_UUID(object, attribute)
object.quoted_id
end
end

class SQLite < Arel::Visitors::ToSql
def visit_UUIDTools_UUID(o)
o.quoted_id
def visit_UUIDTools_UUID(object, attribute)
object.quoted_id
end
end

class PostgreSQL < Arel::Visitors::ToSql
def visit_UUIDTools_UUID(o)
"'#{o.to_s}'"
def visit_UUIDTools_UUID(object, attribute)
"'#{object.to_s}'"
end
end
end
Expand Down Expand Up @@ -114,7 +114,7 @@ def uuids(*attributes)
EOS
end

def instantiate_with_uuid(record)
def instantiate_with_uuid(record, column_types)
uuid_columns.each do |uuid_column|
record[uuid_column] = UUIDTools::UUID.serialize(record[uuid_column]).to_s if record[uuid_column]
end
Expand Down

0 comments on commit 24fee78

Please sign in to comment.