lib/classy-inheritance.rb in johnsbrn-classy-inheritance-0.6.7 vs lib/classy-inheritance.rb in johnsbrn-classy-inheritance-0.6.8
- old
+ new
@@ -5,11 +5,14 @@
def set_belongs_to_association_for(record)
if @reflection.options[:as]
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
else
- record[@reflection.primary_key_name] = @reflection.options.has_key?(:primary_key) ? @owner.send(@reflection.options[:primary_key]) : @owner.id unless @owner.new_record?
+ unless @owner.new_record?
+ primary_key = @reflection.options[:primary_key] || :id
+ record[@reflection.primary_key_name] = @owner.send(primary_key)
+ end
end
end
private
def new_record(replace_existing)
@@ -22,11 +25,14 @@
end
if replace_existing
replace(record, true)
else
- record[@reflection.primary_key_name] = @reflection.options.has_key?(:primary_key) ? @owner.send(@reflection.options[:primary_key]) : @owner.id unless @owner.new_record?
+ unless @owner.new_record?
+ primary_key = @reflection.options[:primary_key] || :id
+ record[@reflection.primary_key_name] = @owner.send(primary_key)
+ end
self.target = record
end
record
end
@@ -34,10 +40,10 @@
end
end
module Stonean
module ClassyInheritance
- VERSION = '0.6.5'
+ VERSION = '0.6.8'
def self.version
VERSION
end