Sha256: 2ea2ac9bacb1a28ddd4d119e57dec0c4d84948aabef592631620f44d2c01f4f2

Contents?: true

Size: 1.53 KB

Versions: 18

Compression:

Stored size: 1.53 KB

Contents

module ThinkingSphinx
  class Source
    module InternalProperties
      def add_internal_attributes_and_facets
        add_internal_attribute :sphinx_internal_id, nil,
          @model.primary_key_for_sphinx.to_sym
        add_internal_attribute :sphinx_deleted,     :integer, "0"
        add_internal_attribute :class_crc,          :integer, crc_column, true
        
        unless Riddle.loaded_version.to_i < 2
          add_internal_attribute :sphinx_internal_class, :string, internal_class_column, true
          add_internal_facet :sphinx_internal_class
        else
          add_internal_facet :class_crc
        end
      end

      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

      def add_internal_facet(name)
        return unless facet_by_alias(name).nil?

        @model.sphinx_facets << ClassFacet.new(attribute_by_alias(name))
      end

      def attribute_by_alias(attr_alias)
        @attributes.detect { |attrib| attrib.alias == attr_alias }
      end

      def facet_by_alias(name)
        @model.sphinx_facets.detect { |facet| facet.name == name }
      end

      def subclasses_to_s
        "'" + (@model.send(:descendants).collect { |klass|
          klass.to_crc32.to_s
        } << @model.to_crc32.to_s).join(",") + "'"
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
friendlyfashion-thinking-sphinx-2.0.14.4 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.1.0 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.14 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/thinking_sphinx/source/internal_properties.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.13 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.12 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.11 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.10 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.9 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.8 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.7 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-2.0.5 lib/thinking_sphinx/source/internal_properties.rb