aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/attribute.rb')
-rw-r--r--activerecord/lib/active_record/attribute.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute.rb b/activerecord/lib/active_record/attribute.rb
index da8eb10dc6..6c0b81b3fe 100644
--- a/activerecord/lib/active_record/attribute.rb
+++ b/activerecord/lib/active_record/attribute.rb
@@ -8,6 +8,10 @@ module ActiveRecord
def from_user(value, type)
FromUser.new(value, type)
end
+
+ def uninitialized(type)
+ Uninitialized.new(type)
+ end
end
attr_reader :value_before_type_cast, :type
@@ -41,6 +45,10 @@ module ActiveRecord
raise NotImplementedError
end
+ def initialized?
+ true
+ end
+
protected
def initialize_dup(other)
@@ -69,6 +77,25 @@ module ActiveRecord
false
end
alias changed_in_place_from? changed_from?
+
+ def initialized?
+ true
+ end
+ end
+ end
+
+ class Uninitialized < Attribute # :nodoc:
+ def initialize(type)
+ super(nil, type)
+ end
+
+ def value
+ nil
+ end
+ alias value_for_database value
+
+ def initialized?
+ false
end
end
end