Sha256: 989c306e2ea27b19f2a22609ee6186fb9cbb58b6fc4f194adebea5b6d7a0ba88

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

module Materialize
  class BaseBuilder
    class << self

      def build(data, options)
        entity_class.new(data)
      end

      def build_all(data, options)
        entity_class.wrap(data)
      end

      def concurrent(*lambdas)
        threads = []
        lambdas.each do |l|
          threads << Thread.new do
            l.()
          end
        end
        threads.each(&:join)
      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

2 entries across 2 versions & 1 rubygems

Version Path
materialize-0.2.2 lib/materialize/base_builder.rb
materialize-0.2.1 lib/materialize/base_builder.rb