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_estraier_doc.rb', line 10
def acts_as_estraier_doc(options = {})
self.extend ClassMethods
send :include, ActsAsEstraierDoc::InstanceMethods
send :alias_method_chain, :to_xml, :estdoc
send :alias_method_chain, :to_json, :estdoc
send :attr_accessor, :estdoc
send :attr_accessor, :skip_update_est_index
cattr_accessor :configuration, :estraier_conn
self.configuration = {
:condition_options => EstraierPure::Condition::SIMPLE,
:depth => 0,
}
self.configuration.update(options) if options.is_a? Hash
self.configuration[:node][:host] = 'localhost' unless self.configuration[:node].include? :host
self.configuration[:node][:port] = 1978 unless self.configuration[:node].include? :port
self.estraier_conn = EstraierPure::Node::new
self.estraier_conn.set_url("http://#{self.configuration[:node][:host]}:#{self.configuration[:node][:port]}/node/#{self.configuration[:node][:node]}")
self.estraier_conn.set_auth(self.configuration[:node][:user], self.configuration[:node][:pass])
after_save :update_est_index
before_destroy :remove_est_index
end
|