Module: DataMapper::Is::List::ClassMethods

### Home Classes Methods

### In Files

- lib/dm-is-list/is/list.rb

### Methods

- #repair_list

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Is
- DataMapper::Is::List
- DataMapper::Is::List::ClassMethods
- DataMapper::Is::List::InstanceMethods

No matching classes.

# DataMapper::Is::List::ClassMethods

### Attributes

list_options[R]

### Public Instance Methods

repair_list(scope = {}) click to toggle source

use this function to repair / build your lists.

@example [Usage]

    MyModel.repair_list # repairs the list, given that lists are not scoped
    MyModel.repair_list(:user_id => 1) # fixes the list for user 1, given that the scope is [:user_id]

@param scope [Hash]

@api public

    # File lib/dm-is-list/is/list.rb, line 316
    def repair_list(scope = {})
      return false unless scope.keys.all?{ |s| list_options[:scope].include?(s) || s == :order }
      retval = true
      all({ :order => [ :position.asc ] | default_order }.merge(scope)).each_with_index do |item, index|
        retval &= item.update(:position => index.succ)
      end
      retval
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.