lib/tailwind_dsl/etl/element.rb in tailwind_dsl-0.0.7 vs lib/tailwind_dsl/etl/element.rb in tailwind_dsl-0.0.8
- old
+ new
@@ -15,8 +15,18 @@
raise guard if value.nil? && guard
value || default
end
+
+ def map_to(klass, data)
+ return nil if data.nil?
+
+ return data if data.is_a?(klass)
+ return klass.new(**data) if data.is_a?(Hash)
+
+ puts "Data of type: #{data.class} cannot be converted to #{klass}"
+ nil
+ end
end
end
end