Sha256: d77aae737893603c62e8ff4d26ef341cec1bbe556878249efa3d877a9d8b905a

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

class <%= @index_name %> < <%= @base_class %>
  module Serializers
    class <%= @type.camelize if @type %>Serializer < Esse::Serializer
      <%- if @cli_options[:active_record] -%>
      delegate :id, to: :object
      <%- else -%>
      def id
        object.id
      end
      <%- end -%>

      def source
        {
          name: object.name,
          <%- if @type -%>
          type: "<%= @type %>",
          <%- end -%>
          <%- if @cli_options[:active_record] -%>
          created_at: object.created_at,
          updated_at: object.updated_at,
          <%- end -%>
        }
      end
      <%- if @type && defined?(Elasticsearch::VERSION) && Elasticsearch::VERSION <= '5' -%>

      def type
        '<%= @type %>'
      end
      <%- end -%>
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esse-0.2.2 lib/esse/cli/templates/serializer.rb.erb