Sha256: 5b8ebb56a41d940383338bd6a0e453c87a0936d3ee582bf37279df4f1a22fbc5
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
module MyFeeds module Identify extend ActiveSupport::Concern included do before_save :save_feed_identify class_attribute :feed_polymorphic_name self.feed_polymorphic_name = self == Feed ? :source : default_feed_polymorphic_name delegate :default_feed_polymorphic_name, :polymorphic_identify_column, :polymorphic_id_column, :polymorphic_type_column, to: :"self.class" end protected def save_feed_identify instance_eval %Q{self.#{polymorphic_identify_column} = "#\{#{polymorphic_id_column}.to_s\}@#\{#{polymorphic_type_column}.to_s.underscore\}"} end private module ClassMethods def default_feed_polymorphic_name self.to_s.underscore end def polymorphic_identify_column :"#{feed_polymorphic_name}_identify" end def polymorphic_id_column :"#{feed_polymorphic_name}_id" end def polymorphic_type_column :"#{feed_polymorphic_name}_type" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_feeds-0.0.1 | lib/my_feeds/identify.rb |