Sha256: b397c31eac0838acfeccb6f082d4f19f5b7248552851826739934c960f9ac062

Contents?: true

Size: 1.38 KB

Versions: 57

Compression:

Stored size: 1.38 KB

Contents

module ThinkingSphinx
  class Source
    module InternalProperties
      def add_internal_attributes_and_facets
        add_internal_attribute :sphinx_internal_id, :integer, @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

      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(:subclasses).collect { |klass|
          klass.to_crc32.to_s
        } << @model.to_crc32.to_s).join(",") + "'"
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 13 rubygems

Version Path
skalee-thinking-sphinx-1.3.14.1 lib/thinking_sphinx/source/internal_properties.rb
hawkerb-thinking-sphinx-1.3.18 lib/thinking_sphinx/source/internal_properties.rb
hawkerb-thinking-sphinx-1.3.17 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.15 lib/thinking_sphinx/source/internal_properties.rb
hawkerb-thinking-sphinx-1.3.16 lib/thinking_sphinx/source/internal_properties.rb
hawkerb-thinking-sphinx-1.3.15 lib/thinking_sphinx/source/internal_properties.rb
hawkerb-thinking-sphinx-1.3.14 lib/thinking_sphinx/source/internal_properties.rb
zipme-thinking-sphinx-1.3.14 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.14 lib/thinking_sphinx/source/internal_properties.rb
warp-thinking-sphinx-1.3.13 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.13 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.12 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.11 lib/thinking_sphinx/source/internal_properties.rb
warp-thinking-sphinx-1.3.11 lib/thinking_sphinx/source/internal_properties.rb
warp-thinking-sphinx-1.3.10 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.10 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.9 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.8 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.7 lib/thinking_sphinx/source/internal_properties.rb
thinking-sphinx-1.3.6 lib/thinking_sphinx/source/internal_properties.rb