lib/acts_as.rb in acts_as-0.6.3 vs lib/acts_as.rb in acts_as-0.6.4

- old
+ new

@@ -16,11 +16,13 @@ current.merge(association_changes) end end def update_column(name, value) - if (association = self.class.acts_as_fields.detect { |k,v| v.include?(name.to_s) }.try(:first)).present? + if attribute_names.include?(name.to_s) + super + elsif (association = self.class.acts_as_fields.detect { |k,v| v.include?(name.to_s) }.try(:first)).present? send(association).update_column name, value else super end end @@ -99,25 +101,12 @@ end def whitelist_and_delegate_fields(association_class, one_association, prefix, with) association_fields = association_class.columns.map(&:name) - PREFIX - prefix + with - build_prefix_methods(one_association, prefix) - delegate(*(association_fields + association_fields.map { |field| "#{field}=" }), to: one_association) + delegate(*(prefix + prefix.map { |field| "#{field}=" }), to: one_association, prefix: true) acts_as_fields[one_association] = association_fields + prefix - end - - def build_prefix_methods(one_association, prefix) - prefix.each do |field| - define_method("#{one_association}_#{field}") do |*args| - send(one_association).send(field, *args) - end - - define_method("#{one_association}_#{field}=") do |*args| - send(one_association).send("#{field}=", *args) - end - end end end end