Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Fix PropertySet's unique_indexes method. #282

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 13 additions & 1 deletion lib/dm-core/property_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def indexes
# @api semipublic
def unique_indexes
index_hash = {}
each { |property| parse_index(property.unique_index, property.field, index_hash) }
each { |property| parse_unique_index(property.unique_index, property.field, index_hash) }
index_hash
end

Expand Down Expand Up @@ -173,5 +173,17 @@ def parse_index(index, property, index_hash)
index.each { |idx| parse_index(idx, property, index_hash) }
end
end

# @api private
def parse_unique_index(index, property, index_hash)
case index
when true
index_hash[property] = [ property ]
when Symbol
index_hash[property] = [ property, index ] if index != :key
when Array
index_hash[property] = [ property ] + index
end
end
end # class PropertySet
end # module DataMapper