Sha256: 5d284b9077ad7abec8110bfdc8ede33d75be716d04211efc9b20d90ff364d2d7
Contents?: true
Size: 825 Bytes
Versions: 1
Compression:
Stored size: 825 Bytes
Contents
class Apisync module ActiveRecordExtension def self.included(klass) klass.extend(ClassMethods) klass.include(InstanceMethods) end module InstanceMethods attr_accessor :apisync private def start_apisync @apisync = Apisync::Rails::Model.new(self) @apisync.instance_eval(&self.class.apisync_block) @apisync.validate! end def save_to_apisync @apisync.sync end end module ClassMethods def apisync_block @apisync_block end def apisync(&block) after_initialize :start_apisync after_commit :save_to_apisync @apisync_block = block end end end end ActiveSupport.on_load(:active_record) do ::ActiveRecord::Base.send(:include, Apisync::ActiveRecordExtension) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apisync-rails-0.0.2 | lib/apisync/active_record_extension.rb |