lib/dynamoid/associations/has_one.rb in dynamoid-0.1.2 vs lib/dynamoid/associations/has_one.rb in dynamoid-0.2.0
- old
+ new
@@ -7,19 +7,27 @@
include Dynamoid::Associations::Association
def ==(other)
target == other
end
+
+ def method_missing(method, *args)
+ if target.respond_to?(method)
+ target.send(method, *args)
+ else
+ super
+ end
+ end
private
def target
records.first
end
def target_association
- key_name = source.class.to_s.pluralize.downcase.to_sym
+ key_name = source.class.to_s.singularize.downcase.to_sym
guess = target_class.associations[key_name]
return nil if guess.nil? || guess[:type] != :belongs_to
key_name
end
@@ -31,6 +39,6 @@
source.update_attribute(source_attribute, nil)
end
end
end
-end
\ No newline at end of file
+end