lib/materialize/base_builder.rb in materialize-0.3.0 vs lib/materialize/base_builder.rb in materialize-0.3.1
- old
+ new
@@ -1,27 +1,27 @@
+require 'pry'
+
module Materialize
class BaseBuilder
extend Concurrent
class << self
+ # Need to attach builder info somehow before we call initialize!
def build(data, repo, options)
- attach_builder_info(entity_class.new(data), repo, options)
+ data = data.merge({ __repo__: repo, __options__: options })
+ entity_class.new(data)
end
def build_all(data, repo, options)
- entity_class.wrap(data).map { |entity| attach_builder_info(entity, 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 attach_builder_info(entity, repo, options)
- entity.__builder_info__ = { repo: repo, options: options }
- entity
- end
def entity_base_class_name
"#{self.name[0..-8]}".split('::').last
end