lib/selectable_attr/enum.rb in akm-selectable_attr-0.3.5 vs lib/selectable_attr/enum.rb in akm-selectable_attr-0.3.7
- old
+ new
@@ -1,5 +1,6 @@
+# -*- coding: utf-8 -*-
module SelectableAttr
class Enum
include Enumerable
@@ -147,10 +148,16 @@
end
def to_hash
(@options || {}).merge(:id => @id, :key => @key, :name => name)
end
-
+
+ def inspect
+ # object_idを2倍にしているのは通常のinspectと合わせるためです。
+ '#<%s:%x @id=%s, @key=%s, @name=%s, @options=%s' % [
+ self.class.name, object_id * 2, id.inspect, key.inspect, name.inspect, @options.inspect]
+ end
+
NULL = new(nil, nil, nil, nil) do
def null?; true; end
def name; nil; end
end
end