lib/active_finite.rb in active_finite-0.1.5 vs lib/active_finite.rb in active_finite-0.2.0

- old
+ new

@@ -1,10 +1,6 @@ -require 'pathname' -require 'find' -require 'active_support/inflector' -require 'active_record' -require 'json' +require_relative 'external_includes.rb' require_relative 'master_table.rb' require_relative 'get_table.rb' def all_finite_tables MasterTable.all @@ -63,11 +59,11 @@ if table_name.nil? raise 'A table name must be specified for :in_table.' end file_name = args[:from_file] values = args[:values] - column_name = args[:column_name] || :value + column_name = args[:column_name] || default_column_name(table_name) if values.nil? and file_name.nil? raise 'Either :from_file or :values must be specified.' end to_be_modified = Array.new @@ -83,12 +79,9 @@ ActiveRecord::Base.transaction do yield to_be_modified, klass, column_name end end -def default_column_name - :value +def default_column_name table_name + table_name.to_s.singularize.to_sym end -def as_class_name table_name - table_name.to_s.singularize.capitalize.to_sym -end