Skip to content

Commit

Permalink
Field#set_indexed_name does what it sounds like
Browse files Browse the repository at this point in the history
Also make it private

[sunspot#149]
  • Loading branch information
outoftime committed Dec 27, 2010
1 parent 55e3dae commit d0d6530
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sunspot/lib/sunspot/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(name, type, options = {}) #:nodoc
@name, @type = name.to_sym, type
@stored = !!options.delete(:stored)
@more_like_this = !!options.delete(:more_like_this)
@indexed_name = set_indexed_name(options)
set_indexed_name(options)
raise ArgumentError, "Field of type #{type} cannot be used for more_like_this" unless type.accepts_more_like_this? or !@more_like_this
end

Expand Down Expand Up @@ -90,6 +90,8 @@ def eql?(field)
end
alias_method :==, :eql?

private

#
# Determine the indexed name. If the :as option is given use that, otherwise
# create the value based on the indexed_name of the type with additional
Expand All @@ -100,11 +102,12 @@ def eql?(field)
# String: The field's indexed name
#
def set_indexed_name(options)
if options[:as]
options.delete(:as)
else
"#{@type.indexed_name(@name).to_s}#{'m' if @multiple }#{'s' if @stored}#{'v' if more_like_this?}"
end
@indexed_name =
if options[:as]
options.delete(:as)
else
"#{@type.indexed_name(@name).to_s}#{'m' if @multiple }#{'s' if @stored}#{'v' if more_like_this?}"
end
end

end
Expand Down

0 comments on commit d0d6530

Please sign in to comment.