Created
January 19, 2012 02:11
-
-
Save woahdae/1637161 to your computer and use it in GitHub Desktop.
alternate indexes implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# leaves around a pointer to the root mapping after use | |
def indexes(name, options = {}, &block) | |
@_mapping_pointer ||= @mapping | |
@_mapping_pointer[name] = options | |
if block_given? | |
previous = @_mapping_pointer | |
@_mapping_pointer[name][:type] ||= 'object' | |
@_mapping_pointer = @_mapping_pointer[name][:properties] = {} | |
yield | |
@_mapping_pointer = previous | |
end | |
@_mapping_pointer[name][:type] ||= 'string' | |
self | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment