Sha256: 7edacb53ea7f6c74a012a386f82877e578b4244b5ac7e65625a1d9b67315c726

Contents?: true

Size: 524 Bytes

Versions: 1

Compression:

Stored size: 524 Bytes

Contents

module ActiveRecord
  module ActsAs
    module Querying
      def where(opts = :chain, *rest)
        if opts.is_a? Hash
          opts, acts_as_opts = opts.partition { |k,v| attribute_names.include?(k.to_s) }
          opts, acts_as_opts = Hash[opts], Hash[acts_as_opts]
          opts[acting_as_model.table_name] = acts_as_opts
        end
        super(opts, *rest)
      end

      def find_by(*args)
        where(*args).take
      end

      def find_by!(*args)
        where(*args).take!
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record-acts_as-1.0.0.pre lib/active_record/acts_as/querying.rb