Sha256: d14d30ddd33db6138e409e7b5fc9fdb0f8bc7b25c7e865eac5b21796c7b25bf8

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module RedhillonrailsCore
  module ActiveRecord
    module Base
      def self.included(base)
        base.extend(ClassMethods)
      end

      module ClassMethods
        def self.extended(base)
          class << base
            alias_method_chain :abstract_class?, :redhillonrails_core
            alias_method_chain :reset_column_information, :redhillonrails_core
          end
        end

        def base_class?
          self == base_class
        end

        def abstract_class_with_redhillonrails_core?
          abstract_class_without_redhillonrails_core? || !(name =~ /^Abstract/).nil?
        end

        def reset_column_information_with_redhillonrails_core
          reset_column_information_without_redhillonrails_core
          @indexes = @foreign_keys = nil
        end

        def pluralized_table_name(table_name)
          ::ActiveRecord::Base.pluralize_table_names ? table_name.to_s.pluralize : table_name
        end

        def indexes
          @indexes ||= connection.indexes(table_name, "#{name} Indexes")
        end

        def foreign_keys
          @foreign_keys ||= connection.foreign_keys(table_name, "#{name} Foreign Keys")
        end

        def reverse_foreign_keys
          connection.reverse_foreign_keys(table_name, "#{name} Reverse Foreign Keys")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redhillonrails_core-2.0.0.pre lib/redhillonrails_core/active_record/base.rb