Sha256: 3a8065e768408375fc9bf24e42f8de1605512e6ffb47c7bb6754aa83f62d8d43
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module MyFeeds module Identify extend ActiveSupport::Concern included do before_save :save_feed_identify self.feed_polymorphic = self == Feed ? :source : default_feed_polymorphic delegate :default_feed_polymorphic, :polymorphic_identify_column, :polymorphic_id_column, :polymorphic_type_column, to: :"self.class" end module ClassMethods def feed_polymorphic @_feed_polymorphic end def feed_polymorphic= polymorphic @_feed_polymorphic = polymorphic class_eval %Q{ def save_feed_identify self.#{polymorphic_identify_column} = "#\{#{polymorphic_id_column}.to_s\}@#\{#{polymorphic_type_column}.to_s.underscore\}" end protected :save_feed_identify } end def default_feed_polymorphic self.to_s.underscore end def polymorphic_identify_column :"#{feed_polymorphic}_identify" end def polymorphic_id_column :"#{feed_polymorphic}_id" end def polymorphic_type_column :"#{feed_polymorphic}_type" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
my_feeds-0.1.1 | lib/my_feeds/identify.rb |
my_feeds-0.1.0 | lib/my_feeds/identify.rb |