Sha256: 2c64087f72e634610644987aaf9e45bc9dccccd1d2582c8a47098e922153ac13

Contents?: true

Size: 443 Bytes

Versions: 1

Compression:

Stored size: 443 Bytes

Contents

module Elastic::Types
  module NestableType
    def nested(_name, using: nil, target: nil, &_block)
      unless _block.nil?
        using = Class.new(Elastic::NestedType, &_block)
        using.target = (target || _name.to_s.singularize.camelize.constantize) rescue nil
      end

      using = (_name + '_index').camelize.constantize if using.nil?

      definition.register_field Elastic::Fields::Nested.new(_name, using)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elastic-rails-0.5.0 lib/elastic/types/nestable_type.rb