Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ActiveRecord 4.x #1

Merged
merged 2 commits into from
Feb 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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