4 # Changes an underscored string into a class reference.
6 # classify expects self to be plural
7 self.classify.constantize
10 # For compatibility with the Symbol extensions.
11 alias :_singularize :singularize
12 alias :_pluralize :pluralize
13 alias :_classify :classify
18 # Changes an underscored symbol into a class reference.
19 def _as_class; self.to_s._as_class; end
21 # Changes a plural symbol into a singular symbol.
22 def _singularize; self.to_s.singularize.to_sym; end
24 # Changes a singular symbol into a plural symbol.
25 def _pluralize; self.to_s.pluralize.to_sym; end
27 # Changes a symbol into a class name string.
28 def _classify; self.to_s.classify; end
33 # Flattens the first level of self.
35 self.inject([]){|r, el| r + Array(el)}
38 # Rails 1.2.3 compatibility method. Copied from http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/core_ext/array/extract_options.rb?rev=7217
40 last.is_a?(::Hash) ? pop : {}
46 # An implementation of select that returns a Hash.
48 Hash[*self.select do |key, value|
56 # Returns the metaclass of self.
57 def _metaclass; (class << self; self; end); end
61 s = "** has_many_polymorphs: #{s}"
62 RAILS_DEFAULT_LOGGER.debug(s) if RAILS_DEFAULT_LOGGER
67 s = "** has_many_polymorphs: #{s}"
68 if RAILS_DEFAULT_LOGGER
69 RAILS_DEFAULT_LOGGER.warn(s)
77 class ActiveRecord::Base
79 # Return the base class name as a string.
81 self.class.base_class.name.to_s