Sha256: ff0120fa99f51401d049862ff5003357449cad34228a7544b3a6abcfe72ce3a7

Contents?: true

Size: 592 Bytes

Versions: 7

Compression:

Stored size: 592 Bytes

Contents

module DynamicModelActiveRecordExtensions

  def self.included(base)
    base.extend(ClassMethods)
  end

  def sti_model?
    attribute_names.include? "type"
  end

  # for creating routes which are based on the parent class
  def sti_parent_class
    self.class.parent
  end

  module ClassMethods

    # if this class has a type attribute, then it is a model which is using single table inheritance
    def sti_model?
      attribute_names.include? "type"
    end

    # for creating routes which are based on the parent class
    def sti_parent_class
      self.parent
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dynamic_models-0.4.8 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.7 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.4 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.3 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.2 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.1 lib/dynamic_model_active_record_extensions.rb
dynamic_models-0.4.0 lib/dynamic_model_active_record_extensions.rb