Module: Hashdown::Finder

Defined in:
lib/hashdown/finder.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Instance Method Details

#finder(attribute, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/hashdown/finder.rb', line 5

def finder(attribute, options={})
  self.extend ClassMethods
  self.send(:include, InstanceMethods)

  hashdown.finder = Config.new(options.merge(:key => attribute))

  validates attribute, :uniqueness => true

  after_save :clear_hashdown_finder_cache
  after_destroy :clear_hashdown_finder_cache
end