Sha256: d196aa40d9fe7ec39b898256b08fb740c92df30f1c61c5a85ddeba7f2206affe

Contents?: true

Size: 638 Bytes

Versions: 7

Compression:

Stored size: 638 Bytes

Contents

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

7 entries across 7 versions & 1 rubygems

Version Path
materialize-0.4.5 lib/materialize/base_builder.rb
materialize-0.4.4 lib/materialize/base_builder.rb
materialize-0.4.3 lib/materialize/base_builder.rb
materialize-0.4.2 lib/materialize/base_builder.rb
materialize-0.4.1 lib/materialize/base_builder.rb
materialize-0.4.0 lib/materialize/base_builder.rb
materialize-0.3.5 lib/materialize/base_builder.rb