Class: ActiveRecordSunspotter::SunspotColumn

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/active_record_sunspotter/sunspot_column.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SunspotColumn

Returns a new instance of SunspotColumn.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/active_record_sunspotter/sunspot_column.rb', line 4

def initialize(*args)
	#	some sensible defaults
	default_options = {
		:group     => 'Main',
		:type      => :string, 
		:orderable => true, 
		:facetable => false, 
		:filterable => false, 
		:multiple  => false, 
		:default   => false
	}
	options = args.extract_options!.with_indifferent_access
	if [String,Symbol].include?( args.first.class ) and !options.has_key?(:name)
		options[:name] = args.first.to_s
	end

	default_options.update(options)
	default_options[:orderable] = false if options[:multiple]
	default_options[:filterable] = true if options[:facetable]
	super default_options
end

Instance Method Details

#hash_tableObject



26
27
28
# File 'lib/active_record_sunspotter/sunspot_column.rb', line 26

def hash_table
	instance_variable_get("@table")
end

#to_sObject



30
31
32
# File 'lib/active_record_sunspotter/sunspot_column.rb', line 30

def to_s
	name
end