Sha256: dd38e9004d31e61dcda6f2aba546ffb5cd23871a33fd8a3e30fc43376ccd34e8
Contents?: true
Size: 637 Bytes
Versions: 2
Compression:
Stored size: 637 Bytes
Contents
module Partisan class Helper # Retrieves the parent class name def self.parent_class_name(obj) # If the object is an ActiveRecord record klass = obj.class if obj.class < ActiveRecord::Base # If the object respond to `object` and the value is an ActiveRecord record klass ||= obj.object.class if obj.respond_to?(:object) && obj.object.class < ActiveRecord::Base # In case we’re using STI, loop back until we find the top-level ActiveRecord model klass = klass.superclass while !klass.superclass.abstract_class && klass.superclass != ActiveRecord::Base klass.name end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
partisan-0.5.1 | lib/partisan/helper.rb |
partisan-0.5 | lib/partisan/helper.rb |