Module: ActsAsTokenizable::ClassMethods

Defined in:
lib/acts_as_tokenizable/acts_as_tokenizable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#token_field_nameObject

Returns the value of attribute token_field_name.



7
8
9
# File 'lib/acts_as_tokenizable/acts_as_tokenizable.rb', line 7

def token_field_name
  @token_field_name
end

Instance Method Details

#acts_as_tokenizable(field_name = :token) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/acts_as_tokenizable/acts_as_tokenizable.rb', line 9

def acts_as_tokenizable(field_name = :token)
  include InstanceMethods
  include TokenizedBy

  before_save :tokenize

  self.token_field_name = field_name
end

#prepare_search_token(search_token) ⇒ Object

search_token parameter is used by tokenized_by. This function allows for preparation before tokenized_by function is invoked. Usually this means removing stop words, replacing words. By default it tokenizes each word and removes duplicates.



22
23
24
# File 'lib/acts_as_tokenizable/acts_as_tokenizable.rb', line 22

def prepare_search_token(search_token)
  StringUtils.words_to_token(search_token)
end