Module: Dynamoid::Indexes::ClassMethods
- Defined in:
- lib/dynamoid/indexes.rb
Instance Method Summary (collapse)
-
- (Object) create_indexes
Helper function to create indexes (if they don't exist already).
-
- (Object) find_index(index)
Helper function to find indexes.
-
- (Object) index(name, options = {})
The call to create an index.
Instance Method Details
- (Object) create_indexes
Helper function to create indexes (if they don't exist already).
41 42 43 44 45 46 47 |
# File 'lib/dynamoid/indexes.rb', line 41 def create_indexes self.indexes.each do |name, index| opts = {:table_name => index.table_name, :id => :id} opts[:range_key] = { :range => :number } if index.range_key? self.create_table(opts) end end |
- (Object) find_index(index)
Helper function to find indexes.
34 35 36 |
# File 'lib/dynamoid/indexes.rb', line 34 def find_index(index) self.indexes[Array(index).collect(&:to_s).sort.collect(&:to_sym)] end |
- (Object) index(name, options = {})
The call to create an index. Generates a new index with the specified options -- for more information, see Dynamoid::Indexes::Index. This function also attempts to immediately create the indexing table if it does not exist already.
25 26 27 28 29 |
# File 'lib/dynamoid/indexes.rb', line 25 def index(name, = {}) index = Dynamoid::Indexes::Index.new(self, name, ) self.indexes[index.name] = index create_indexes end |