Module: ActivityNotification::Association
- Extended by:
- ActiveSupport::Concern
- Included in:
- ORM::Dynamoid::Notification, ORM::Dynamoid::Subscription, ORM::Mongoid::Notification, ORM::Mongoid::Subscription
- Defined in:
- lib/activity_notification/orm/mongoid.rb,
lib/activity_notification/orm/dynamoid.rb,
lib/activity_notification/orm/active_record.rb
Instance Method Summary collapse
-
#update(attributes) ⇒ Object
Defines update method as update_attributes method.
Instance Method Details
#update(attributes) ⇒ Object
Defines update method as update_attributes method
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/activity_notification/orm/dynamoid.rb', line 95 def update(attributes) attributes_with_association = attributes.map { |attribute, value| self.class._associated_composite_records.include?(attribute) ? ["#{attribute}_key".to_sym, value.nil? ? nil : "#{value.class.name}#{ActivityNotification.config.composite_key_delimiter}#{value.id}"] : [attribute, value] }.to_h # Use update_attributes if available, otherwise use the manual approach if respond_to?(:update_attributes) update_attributes(attributes_with_association) else # Manual update for models that don't have update_attributes attributes_with_association.each { |attribute, value| write_attribute(attribute, value) } save end end |