Topic: Checking for defaults

Hey guys, i'm creating a module to check for default foreign key IDs that we're setting with each initialization. Here's what i've got so far:

module DefaultChecker
   
    #returns true if
    def has_defaults?
        !return_defaults.empty?
    end
   
    #returns array of columns that are "default" (_id == 1)
    def return_defaults
        ids = self.attributes.select{ |k,v| (k.index("_id") == k.length-3) && v == 1 } if self.respond_to?('attributes')
        ids ||= {}
    end
   
end

Any suggestions?

Re: Checking for defaults

ah, found the reg exp that checks for end of string:

module DefaultChecker
   
    #returns true if
    def has_defaults?
        !return_defaults.empty?
    end
   
    #returns array of columns that are "default" (_id == 1)
    def return_defaults
        ids = self.attributes.select{ |k,v| k.match(/_id$/) && v == 1 } if self.respond_to?('attributes')
        ids ||= {}
    end
   
end

-Thats as good as I can get it