lib/active_groonga/base.rb in activegroonga-1.0.7 vs lib/active_groonga/base.rb in activegroonga-2.1.1
- old
+ new
@@ -20,11 +20,10 @@
module ActiveGroonga
class Base
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::AttributeMethods
- attribute_method_suffix ""
attribute_method_suffix "="
cattr_accessor :logger, :instance_writer => false
cattr_reader :database_path, :instance_reader => false
@@ -186,11 +185,14 @@
define_attribute_methods(attribute_names)
end
def inspect
return super if table.nil?
- columns_info = table.columns.collect do |column|
+ sorted_columns = table.columns.sort_by do |column|
+ column.local_name
+ end
+ columns_info = sorted_columns.collect do |column|
"#{column.local_name}: #{column.range.name}"
end
"#{name}(#{columns_info.join(', ')})"
end
@@ -347,10 +349,13 @@
if table.support_key?
inspected_attributes << "key: #{key}"
else
inspected_attributes << "id: #{id}"
end
- @attributes.each do |key, value|
+ sorted_attributes = @attributes.sort_by do |key, _|
+ key
+ end
+ sorted_attributes.each do |key, value|
inspected_attributes << "#{key}: #{value.inspect}"
end
"\#<#{self.class.name} #{inspected_attributes.join(', ')}>"
end