Module: ThinkingSphinx::Source::InternalProperties
- Included in:
- ThinkingSphinx::Source
- Defined in:
- lib/thinking_sphinx/source/internal_properties.rb
Instance Method Summary collapse
- #add_internal_attribute(name, type, contents, facet = false) ⇒ Object
- #add_internal_attributes_and_facets ⇒ Object
- #add_internal_facet(name) ⇒ Object
- #attribute_by_alias(attr_alias) ⇒ Object
- #facet_by_alias(name) ⇒ Object
- #subclasses_to_s ⇒ Object
Instance Method Details
#add_internal_attribute(name, type, contents, facet = false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 14 def add_internal_attribute(name, type, contents, facet = false) return unless attribute_by_alias(name).nil? Attribute.new(self, ThinkingSphinx::Index::FauxColumn.new(contents), :type => type, :as => name, :facet => facet, :admin => true ) end |
#add_internal_attributes_and_facets ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 4 def add_internal_attributes_and_facets add_internal_attribute :sphinx_internal_id, nil, @model.primary_key_for_sphinx.to_sym add_internal_attribute :class_crc, :integer, crc_column, true add_internal_attribute :subclass_crcs, :multi, subclasses_to_s add_internal_attribute :sphinx_deleted, :integer, "0" add_internal_facet :class_crc end |
#add_internal_facet(name) ⇒ Object
26 27 28 29 30 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 26 def add_internal_facet(name) return unless facet_by_alias(name).nil? @model.sphinx_facets << ClassFacet.new(attribute_by_alias(name)) end |
#attribute_by_alias(attr_alias) ⇒ Object
32 33 34 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 32 def attribute_by_alias(attr_alias) @attributes.detect { |attrib| attrib.alias == attr_alias } end |
#facet_by_alias(name) ⇒ Object
36 37 38 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 36 def facet_by_alias(name) @model.sphinx_facets.detect { |facet| facet.name == name } end |
#subclasses_to_s ⇒ Object
40 41 42 43 44 |
# File 'lib/thinking_sphinx/source/internal_properties.rb', line 40 def subclasses_to_s "'" + (@model.send(:subclasses).collect { |klass| klass.to_crc32.to_s } << @model.to_crc32.to_s).join(",") + "'" end |