Permalink
Browse files

Almost have my API redesign working. 1 more test to go...

  • Loading branch information...
1 parent 4be1874 commit 9e0ba24edc8981e3fdc1c136ddb192a18e73e994 Evan Light committed Mar 15, 2013
Showing with 14 additions and 6 deletions.
  1. +13 −0 lib/edr/registry.rb
  2. +1 −6 spec/test_data.rb
View
@@ -26,6 +26,9 @@ def self.map_models_to_mappers
next unless Object.const_defined?(model_name)
model_class = Object.const_get(model_name)
+
+ instrument(model_class, with: o)
+
@instance.map(model_class, o)
end
end
@@ -57,6 +60,16 @@ def model_class_for data_class
private
+ def self.instrument(model_class, args = {})
+ data_class = args[:with]
+ model_class.send(:include, Edr::Model)
+ model_class.fields(*data_class.attribute_names)
+# binding.pry
+ model_class.wrap_associations(
+ *data_class.reflect_on_all_associations.map(&:name)
+ )
+ end
+
def model_to_data_map
@model_to_data_map
end
View
@@ -55,12 +55,7 @@ class Item
# STEP3: map data objects to domain objects
# --------------------------------------------------
-Edr::Registry.define do
-# NOTE: Below should be implicit by naming convention
-# map Order, OrderData
-# map Item, ItemData
-end
-
+Edr::Registry.map_models_to_mappers
# STEP4: Define repository to access data

0 comments on commit 9e0ba24

Please sign in to comment.