Module: ActsAsActivateable::ClassMethods

Defined in:
lib/acts_as_activateable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_activateable(options = {}) ⇒ Object

Makes a model searchable. Takes a list of fields to use to create the index. It also take an option (:check_for_changes, which defaults to true) to tell the engine wether it should check if the value of a given instance has changed before it actually updates the associated fulltext row. If option :parent_id is not nulled, it is used as the field to be used as the parent of the record, which is useful if you want to limit your queries to a scope. If option :conditions is given, it should be a string containing a ruby expression that equates to true or nil/false. Records are tested with this condition and only those that return true add/update the FullTextRow. A record returning false that is already in FullTextRow is removed.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/acts_as_activateable.rb', line 17

def acts_as_activateable(options = {})
    configuration = { :column => "active"}
    configuration.update(options) if options.is_a?(Hash)
    class_eval "\n      def acts_as_activateable_class\n        ::\#{self.name}\n      end\n\n      def enabled_column\n        '\#{configuration[:column]}'\n      end\n    EOV\n\n  extend  ActsAsActivateableClassMethods\n   include ActsAsActivateableInstanceMethods\nend\n"