3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/acts_as_cleo/acts_methods.rb', line 3
def acts_as_cleo(opts = {})
extend ClassMethods
include InstanceMethods
after_create :create_cleo
after_update :update_cleo
before_destroy :remove_from_cleo
cattr_accessor :cleo_config
self.cleo_config = {}
opts[:except] ||= []
opts[:except] += %w{id created_at updated_at}
self.cleo_config[:type] = opts[:type] || self.ancestors.first.name
self.cleo_config[:name] = opts[:name].blank? ? "name" : opts[:name]
self.cleo_config[:terms] = opts[:terms] || self.column_names
self.cleo_config[:terms] = self.cleo_config[:terms] - opts[:except]
opts[:score] ||= "id"
self.cleo_config[:score] = opts[:score]
end
|