Sha256: 03c5baa958c137e0ce63482d97d27e3fad1f1255a457cbd8988845826e2eec7a
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
module PloymorphicModule def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_wuid options={} default_options = { :as => :wuidable, :dependent => :destroy } default_options.merge!(options) unless options.empty? has_one :wuid, default_options include PloymorphicModule::InstanceMethods end end module InstanceMethods def wid self.wuid.id rescue nil end def after_create super create_wuid end def create_wuid begin wuid.create! rescue ActiveRecord::StatementInvalid => e logger.error " create wuid faild with #{e.message}" retry end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ploymorphic_wuid-0.5.0 | lib/wuid/ploymorphic_module.rb |