# File lib/state_machine/machine.rb, line 1411 def define_scopes(custom_plural = nil) plural = custom_plural || (name.to_s.respond_to?(:pluralize) ? name.to_s.pluralize : "#{name}s") [name, plural].uniq.each do |name| [:with, :without].each do |kind| method = "#{kind}_#{name}" if scope = send("create_#{kind}_scope", method) # Converts state names to their corresponding values so that they # can be looked up properly define_class_method(method) do |machine, klass, *states| values = states.flatten.map {|state| machine.states.fetch(state).value} scope.call(klass, values) end end end end end