Sha256: c6a567dddf059efa5a5fdd343a8b69839c61bb759ee3de2320da99e5c035936c
Contents?: true
Size: 1008 Bytes
Versions: 2
Compression:
Stored size: 1008 Bytes
Contents
require 'active_support/concern' module SocialStream #:nodoc: module Models module Supertype extend ActiveSupport::Concern included do subtypes.each do |s| has_one s, :dependent => :destroy end end module ClassMethods def subtypes SocialStream.__send__ to_s.tableize end def load_subtype_features features = "SocialStream::Models::#{ to_s }".constantize subtypes.each do |s| begin s = s.to_s.classify.constantize s.__send__(:include, features) unless s.ancestors.include?(features) rescue puts "Warning: could not load #{ s.to_s.classify }" end end end end module InstanceMethods def subtype_instance self.class.subtypes.each do |s| i = __send__(s) return i if i.present? end nil end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
social_stream-0.0.4 | lib/social_stream/models/supertype.rb |
social_stream-0.0.3 | lib/social_stream/models/supertype.rb |