Module ActiveRecord::Hates::IN::ClassMethods
In: lib/hates_in.rb

Methods

Public Instance methods

base.rb line 481 in rails 1.2.5

[Source]

    # File lib/hates_in.rb, line 19
19:         def delete_with_hates_of_in(id)
20:           key = connection.quote_column_name(primary_key)
21:           if id.is_a?(Array)
22:             unless id.empty?
23:               sql = id.map {|x| "#{key} = ?"}.join(" OR ")
24:               id.unshift("(#{sql})")
25:               delete_all(id)
26:             end
27:           else
28:             delete_all(["#{key} = ?", id])
29:           end
30:         end

base.rb line 1035 in rails 1.2.5

[Source]

    # File lib/hates_in.rb, line 33
33:         def find_some_with_hates_of_in(ids, options)
34:           conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
35:           key = connection.quote_column_name(primary_key)
36:           pk = columns_hash[primary_key]
37:           if ids.empty?
38:             options.update :conditions => "(0 = 1)#{conditions}"
39:           else
40:             sql = ids.map {|id| "#{table_name}.#{key} = #{quote_value(id, pk)}"}.join(" OR ")
41:             options.update :conditions => "(#{sql})#{conditions}"
42:           end
43:           result = find_every(options)
44:           if result.size == ids.size
45:             result
46:           else
47:             raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
48:           end
49:         end

base.rb line 1403 in rails 1.2.5

[Source]

    # File lib/hates_in.rb, line 56
56:         def sanitize_sql_hash_with_hates_of_in(attrs)
57:           conditions = attrs.map do |attr, value|
58:             if value.is_a?(Array)
59:               if value.empty?
60:                 "(0 = 1)"
61:               else
62:                 key = connection.quote_column_name(attr)
63:                 sql = value.map {|v| "#{table_name}.#{key} #{attribute_condition(v)}"}.join(" OR ")
64:                 "(#{sql})"
65:               end
66:             else
67:               "#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
68:             end
69:           end.join(' AND ')
70:           replace_bind_variables(conditions, expand_range_bind_variables(attrs.values.flatten))
71:         end

[Validate]