Parent

Methods

GettextI18nRails::ModelAttributesFinder

Public Instance Methods

find(options) click to toggle source

options:

:ignore_tables => ['cars',/_settings$/,...]
:ignore_columns => ['id',/_id$/,...]

current connection ---> {'cars'=>,...}

# File lib/gettext_i18n_rails/model_attributes_finder.rb, line 39
def find(options)
  found = Hash.new([])

  connection = ActiveRecord::Base.connection
  connection.tables.each do |table_name|
    next if ignored?(table_name,options[:ignore_tables])
    connection.columns(table_name).each do |column|
      found[table_name] += [column.name] unless ignored?(column.name,options[:ignore_columns])
    end
  end

  found
end
ignored?(name,patterns) click to toggle source
# File lib/gettext_i18n_rails/model_attributes_finder.rb, line 53
def ignored?(name,patterns)
  return false unless patterns
  patterns.detect{|p|p.to_s==name.to_s or (p.is_a?(Regexp) and name=~p)}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.