Sha256: c8a1a25ea13b405e9e559df27e05a837d3e2dd8133b4d1b5880bdeeb252fe7bb

Contents?: true

Size: 1.03 KB

Versions: 25

Compression:

Stored size: 1.03 KB

Contents

module Elastics
  module ClassProxy
    module ModelIndexer

      module Types
        extend self

        attr_accessor :parents
        @parents = []
      end

      attr_reader :parent_association, :parent_child_map

      def init
        variables.deep_merge! :type  => Utils.class_name_to_type(context.name)
      end

      def parent(parent_association, map)
        @parent_association = parent_association
        Types.parents      |= map.keys.map(&:to_s)
        self.type           = map.values.map(&:to_s)
        @parent_child_map   = map
        @is_child           = true
      end

      def is_child?
        !!@is_child
      end

      def is_parent?
        @is_parent ||= Types.parents.include?(type)
      end

      def default_mapping
        default = {}.extend Struct::Mergeable
        if is_child?
          parent_child_map.each do |parent, child|
            default.deep_merge! index => {'mappings' => {child => {'_parent' => {'type' => parent}}}}
          end
        end
        default
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
elastics-models-1.3.3 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.3.2 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.3.1 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.3.0 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.2.1 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.2.0 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.11 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.10 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.9 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.8 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.7 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.6 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.5 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.4 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.3 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.2 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.1 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.1.0 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.0.10 lib/elastics/class_proxy/model_indexer.rb
elastics-models-1.0.9 lib/elastics/class_proxy/model_indexer.rb