Sha256: 4983c6f018e1e34cb74f16e0f48b41e54ade329bc0743fdb021c622d1aa4d52f
Contents?: true
Size: 661 Bytes
Versions: 19
Compression:
Stored size: 661 Bytes
Contents
module ApiResource module Observing extend ActiveSupport::Concern include ActiveModel::Observing # Redefine these methods to included do %w( create save update destroy ).each do |method| alias_method_chain method, :observers end %w( create save update destroy ).each do |method| module_eval <<-EOE, __FILE__, __LINE__ + 1 def #{method}_with_observers(*args) notify_observers(:before_#method) if result = #{method}_without_observers(*args) notify_observers(:after_#{method}) end return result end EOE end end end
Version data entries
19 entries across 19 versions & 1 rubygems