Sha256: bc9507afc006e1d63377288842f52be693d4c078efea87327e4d3b8d295ab40f

Contents?: true

Size: 653 Bytes

Versions: 3

Compression:

Stored size: 653 Bytes

Contents

require 'pry'

module Materialize
  class BaseBuilder
    extend Concurrent
    class << self

      def build(data, repo, options)
        data = data.merge({ __repo__: repo, __options__: options })
        entity_class.new(data)
      end

      def build_all(data, repo, options)
        datas = data.map { |d| d.merge({ __repo__: repo, __options__: options }) }
        entity_class.wrap(datas)
      end

      def entity_class
        "Entities::#{entity_base_class_name}".split('::').reduce(Module, :const_get)
      end

      private

      def entity_base_class_name
        "#{self.name[0..-8]}".split('::').last
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
materialize-0.3.4 lib/materialize/base_builder.rb
materialize-0.3.3 lib/materialize/base_builder.rb
materialize-0.3.2 lib/materialize/base_builder.rb