Sha256: 40637093d6e7ef7c2c31927dbd531e37648101641aeb09fc1c25924e4c2d64b7

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

require 'active_support/concern'

module Perimeter
  module Backend
    module Adapters
      module ActiveRecord
        extend ActiveSupport::Concern

        included do
          begin
            # ActiveRecord >= 3.2.1
            self.table_name = perimeter_table_name
          rescue NoMethodError => e
            # ActiveRecord < 3.2.1
            set_table_name perimeter_table_name
          end
        end

        module ClassMethods

          def perimeter_table_name(*args)
            @perimeter_table_name = args.first unless args.empty?
            @perimeter_table_name || default_perimeter_table_name
          end

          def default_perimeter_table_name
            name.split('::')[-2].underscore
          end

        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perimeter-activerecord-0.0.4 lib/perimeter/backend/adapters/active_record.rb
perimeter-activerecord-0.0.2 lib/perimeter/backend/adapters/active_record.rb
perimeter-activerecord-0.0.1 lib/perimeter/backend/adapters/active_record.rb