Module: ActiveRecordSunspotter::Sunspotability::ClassMethods

Defined in:
lib/active_record_sunspotter/sunspotability.rb

Instance Method Summary collapse

Instance Method Details

#add_sunspot_column(*args) ⇒ Object



16
17
18
# File 'lib/active_record_sunspotter/sunspotability.rb', line 16

def add_sunspot_column(*args)
	all_sunspot_columns.push( ActiveRecordSunspotter::SunspotColumn.new( *args ) )
end

#searchable_plus(&block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/active_record_sunspotter/sunspotability.rb', line 64

def searchable_plus(&block)
	searchable do
		#
		#	Trying to simplify.  Simplify?  Minimize?
		#	Will I need all of the above methods after this is done?
		#
#	.select{|c| c.facetable }
#	or just use "sunspot_all_facets" instead of "all_sunspot_columns"
#	WAIT!  If aren't indexed, then can't be sorted on.
		all_sunspot_columns.select{|c| ![:boolean,:nulled_string].include?(c.type) }.each{|c|
			options = {}
			options[:multiple] = true if( c.multiple )
#
#	I don't think that trie works with :long or :double
#	I got this when I tried a :double
#	Trie fields are only valid for numeric and time types
#
#	I found documentation that says that Lucene/Solr should work for longs and doubles?
#
#
#	these are missing in sunspot 2.0.  I added them in my taxonomy app
#
#	module Sunspot::Type
#		class TrieDoubleType < DoubleType
#			def indexed_name(name)
#				"#{super}t"
#			end
#		end
#		class TrieLongType < LongType
#			def indexed_name(name)
#				"#{super}t"
#			end
#		end
#	end
#
#					options[:trie] = true if( [:integer,:long,:double,:float,:time].include?(c.type) )
			options[:trie] = true if( [:integer,:float,:time].include?(c.type) )
			send( c.type, c.name, options ){
				c.hash_table.has_key?(:meth) ? c.meth.call(self) : send( c.name )
			}
	#
	#	booleans? nulled_strings?
	#
		}
	
	
	#			yield if block_given?
	#			yield block if block_given?
	end	
	
	#	this works, but why can't I just yield inside the block
	searchable &block if block_given?
	
end

#sunspot_all_facet_namesObject



44
45
46
# File 'lib/active_record_sunspotter/sunspotability.rb', line 44

def sunspot_all_facet_names
	sunspot_all_facets.collect(&:name)
end

#sunspot_all_facetsObject

in the order that they will appear on the page



41
42
43
# File 'lib/active_record_sunspotter/sunspotability.rb', line 41

def sunspot_all_facets
	all_sunspot_columns.select{|c|c.facetable}
end

#sunspot_all_filtersObject



36
37
38
# File 'lib/active_record_sunspotter/sunspotability.rb', line 36

def sunspot_all_filters
	all_sunspot_columns.select{|c|c.filterable}
end

#sunspot_available_column_namesObject



56
57
58
# File 'lib/active_record_sunspotter/sunspotability.rb', line 56

def sunspot_available_column_names
	sunspot_column_names.sort
end

#sunspot_column_namesObject



52
53
54
# File 'lib/active_record_sunspotter/sunspotability.rb', line 52

def sunspot_column_names
	all_sunspot_columns.collect(&:name)
end

#sunspot_columnsObject



48
49
50
# File 'lib/active_record_sunspotter/sunspotability.rb', line 48

def sunspot_columns
	all_sunspot_columns
end

#sunspot_date_columnsObject



60
61
62
# File 'lib/active_record_sunspotter/sunspotability.rb', line 60

def sunspot_date_columns
	all_sunspot_columns.select{|c|c.type == :date }
end

#sunspot_default_column_namesObject



32
33
34
# File 'lib/active_record_sunspotter/sunspotability.rb', line 32

def sunspot_default_column_names
	sunspot_default_columns.collect(&:name)
end

#sunspot_default_columnsObject



28
29
30
# File 'lib/active_record_sunspotter/sunspotability.rb', line 28

def sunspot_default_columns
	all_sunspot_columns.select{|c|c.default}
end

#sunspot_orderable_column_namesObject



24
25
26
# File 'lib/active_record_sunspotter/sunspotability.rb', line 24

def sunspot_orderable_column_names
	sunspot_orderable_columns.collect(&:name)
end

#sunspot_orderable_columnsObject



20
21
22
# File 'lib/active_record_sunspotter/sunspotability.rb', line 20

def sunspot_orderable_columns
	all_sunspot_columns.select{|c|c.orderable}
end