lib/transcriber/resource/key/association.rb in transcriber-0.0.8 vs lib/transcriber/resource/key/association.rb in transcriber-0.0.9

- old
+ new

@@ -22,8 +22,14 @@ end def resource_class @class_name.constantize end + + def from_hash(attrs) + return nil if attrs.nil? or attrs.empty? + one? ? resource_class.new(attrs) + : Array(attrs).map {|item| resource_class.new(item)} + end end end end