module DataMapper::Is::Indexed::ClassMethods
Public Instance Methods
[](*keys)
click to toggle source
Allows querying the indexed properties of a Model.
@param [Array, Range, Integer, Object] keys
The key to use when querying the Model. If the key is an Integer or a Range, it will select multiple Resources of the Model.
@return [DataMapper::Collection, DataMapper::Resource, nil]
The selected Resource or Resources.
Calls superclass method
# File lib/dm-is-indexed/is/indexed.rb, line 22 def [](*keys) if keys.length > 1 super(*keys) else key = keys[0] case key when Integer, Range super(*keys) else resource = nil properties.each do |field| if (field.index || field.unique?) if field.valid?(key) resource = first(field => key) break if resource end end end return resource end end end