lib/active_remote/association.rb in active_remote-6.0.1 vs lib/active_remote/association.rb in active_remote-6.0.2

- old
+ new

@@ -82,11 +82,11 @@ search_hash.values.any?(&:nil?) ? [] : klass.search(search_hash) end options[:has_many] = true - create_setter_method(has_many_class, options) + create_association_writer(has_many_class, options) end # Create a `has_one` association for a given remote resource. # Specify one or more associations to define. The constantized # class must be loaded into memory already. A method will be defined @@ -131,16 +131,15 @@ raise "Could not find attribute: '#{options[:scope]}' on #{associated_class}" unless associated_class.public_instance_methods.include?(options[:scope]) end private - def create_setter_method(associated_klass, options = {}) - writer_method = "#{associated_klass}=".to_sym - define_method(writer_method) do |new_value| + def create_association_writer(associated_klass, options = {}) + define_method("#{associated_klass}=") do |new_value| raise "New value must be an array" if options[:has_many] == true && new_value.class != Array - instance_variable_set(:"@#{new_value.class.name.demodulize.underscore}", new_value) + instance_variable_set(:"@#{associated_klass}", new_value) new_value end end def perform_association(associated_klass, options = {}) @@ -158,10 +157,10 @@ end return value end - create_setter_method(associated_klass, options) + create_association_writer(associated_klass, options) end end end end