module Flex::ClassProxy::ModelIndexer

Attributes

parent_association[R]
parent_child_map[R]

Public Instance Methods

default_mapping() click to toggle source
# File lib/flex/class_proxy/model_indexer.rb, line 34
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
init() click to toggle source
# File lib/flex/class_proxy/model_indexer.rb, line 14
def init
  variables.deep_merge! :type  => Utils.class_name_to_type(context.name)
end
is_child?() click to toggle source
# File lib/flex/class_proxy/model_indexer.rb, line 26
def is_child?
  !!@is_child
end
is_parent?() click to toggle source
# File lib/flex/class_proxy/model_indexer.rb, line 30
def is_parent?
  @is_parent ||= Types.parents.include?(type)
end
parent(parent_association, map) click to toggle source
# File lib/flex/class_proxy/model_indexer.rb, line 18
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