Sha256: 9f6c033dca01785e6207eb950c6b973c084fc0a9faaa5dd1771516afcc0d9e99
Contents?: true
Size: 1002 Bytes
Versions: 1
Compression:
Stored size: 1002 Bytes
Contents
module MyFeeds module Identity extend ActiveSupport::Concern included do before_save :save_feed_identity init_feeds_polymorphic :source if self == Feed delegate :polymorphic_identity_column, :polymorphic_id_column, :polymorphic_type_column, to: :"self.class" end module ClassMethods def feed_polymorphic @_feed_polymorphic end def init_feeds_polymorphic polymorphic @_feed_polymorphic = polymorphic class_eval %Q{ def save_feed_identity self.#{polymorphic_identity_column} = "#\{#{polymorphic_id_column}.to_s\}:#\{#{polymorphic_type_column}.to_s.underscore\}" end protected :save_feed_identity } end def polymorphic_identity_column :"#{feed_polymorphic}_identity" end def polymorphic_id_column :"#{feed_polymorphic}_id" end def polymorphic_type_column :"#{feed_polymorphic}_type" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_feeds-1.0.0 | lib/my_feeds/identity.rb |