Module: DataMapper::Is::Searchable

### Home Classes Methods

### In Files

- lib/dm-is-searchable/is/searchable.rb

### Namespace

- MODULE DataMapper::Is::Searchable::ClassMethods

### Methods

- #is_searchable

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Is
- DataMapper::Is::Searchable
- DataMapper::Is::Searchable::ClassMethods
- DataMapper::Model

No matching classes.

# DataMapper::Is::Searchable

### Public Instance Methods

is_searchable(options = {}) click to toggle source

    # File lib/dm-is-searchable/is/searchable.rb, line 5
    def is_searchable(options = {})
      search_repository = options.delete(:repository) || :search
      @search_repository = search_repository

      extend ClassMethods

      after(:save) do |success, *args|
        if success
          # We use the adapter directly to bypass our after :save,
          # and because create caches the repository and new_record? state.
          DataMapper.repository(search_repository).adapter.create([self])
        end
      end

      after(:destroy) do |success|
        if success
          # Since this is after the model has been destroyed, it is
          # a new record, and a simple to_query will return nil.
          query = model.to_query(repository, key, {})
          DataMapper.repository(search_repository).adapter.delete(query)
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.