Sha256: babc5155e0a33e5253ec2f414e5c71f506039b0dfa28e1158f7b405895b3f8b3

Contents?: true

Size: 781 Bytes

Versions: 4

Compression:

Stored size: 781 Bytes

Contents

module Mobility
=begin

Module loading ActiveRecord-specific classes for Mobility models.

=end
  module ActiveRecord
    require "mobility/active_record/uniqueness_validator"

    class QueryMethod < Module
      def initialize(query_method)
        module_eval <<-EOM, __FILE__, __LINE__ + 1
          def #{query_method}
            all
          end
        EOM
      end
    end

    def self.included(model_class)
      model_class.extend QueryMethod.new(Mobility.query_method)
      unless model_class.const_defined?(:UniquenessValidator)
        model_class.const_set(:UniquenessValidator,
                              Class.new(::Mobility::ActiveRecord::UniquenessValidator))
      end
      model_class.delegate :translated_attribute_names, to: :class
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mobility-0.4.3 lib/mobility/active_record.rb
mobility-0.4.2 lib/mobility/active_record.rb
mobility-0.4.1 lib/mobility/active_record.rb
mobility-0.4.0 lib/mobility/active_record.rb