lib/maintain/maintainer.rb in maintain-0.1.5 vs lib/maintain/maintainer.rb in maintain-0.1.6

- old
+ new

@@ -18,11 +18,16 @@ end EOC end # Now define the state if @active_record && method_free?(name, true) - maintainee.named_scope name, :conditions => {@attribute => options} + conditions = {:conditions => {@attribute => options.map{|value| states[value]}}} + if defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::STRING >= "3" + maintainee.scope name, conditions + else + maintainee.named_scope name, conditions + end end end def aggregates @aggregates ||= {} @@ -103,11 +108,15 @@ end value ||= name states[name] = {:compare_value => !@bitmask && value.is_a?(Integer) ? value : @increment, :value => value} @increment += 1 if @active_record && !maintainee.respond_to?(name) - conditions = {} - maintainee.named_scope name, :conditions => {@attribute => value.is_a?(Symbol) ? value.to_s : value} + conditions = {:conditions => {@attribute => value.is_a?(Symbol) ? value.to_s : value}} + if defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::STRING >= "3" + maintainee.scope name, conditions + else + maintainee.named_scope name, conditions + end end # Now we're going to add proxies to test for state. These methods only get added if a # method of their name doesn't already exist. boolean_method = "#{name}?" \ No newline at end of file