97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/facetious.rb', line 97
def facet *args
respond_to?(:facets) or extend FacetedClassMethods
facet_name = args.first.is_a?(Hash) ? args[-1][:name] : args.shift
unless facet_name
raise "Usage: facet :field_name, :title => 'Field Name', :data_type => :string (etc), :where => 'SQL'"
end
field_name = (args.first.is_a?(Hash) ? args[-1][:field_name] : args.shift) || facet_name
title = (args.first.is_a?(Hash) ? args[-1][:title] : args.shift) || facet_name
data_type = (args.first.is_a?(Hash) ? args[-1][:data_type] : args.shift) || :string
where = args.first.is_a?(Hash) ? args[-1][:where] : args.shift
f = self.facets[facet_name] = Facet.new(facet_name, field_name, title, data_type, where)
end
|