Class: ActiveRecord::Coders::YAMLColumn
Do not use. This class is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ColumnSerializer
|
|
Instance Chain:
self,
ColumnSerializer
|
|
Inherits: |
ActiveRecord::Coders::ColumnSerializer
|
Defined in: | activerecord/lib/active_record/coders/yaml_column.rb |
Class Method Summary
- .new(attr_name, object_class = Object, permitted_classes: [], unsafe_load: nil) ⇒ YAMLColumn constructor
ColumnSerializer
- Inherited
Instance Attribute Summary
ColumnSerializer
- Inherited
Instance Method Summary
ColumnSerializer
- Inherited
#assert_valid_value | Public because it’s called by |
#dump, #init_with, #load, #check_arity_of_constructor |
Constructor Details
.new(attr_name, object_class = Object, permitted_classes: [], unsafe_load: nil) ⇒ YAMLColumn
# File 'activerecord/lib/active_record/coders/yaml_column.rb', line 59
def initialize(attr_name, object_class = Object, permitted_classes: [], unsafe_load: nil) super( attr_name, SafeCoder.new(permitted_classes: permitted_classes || [], unsafe_load: unsafe_load), object_class, ) check_arity_of_constructor end
Instance Method Details
#check_arity_of_constructor (private)
[ GitHub ]# File 'activerecord/lib/active_record/coders/yaml_column.rb', line 88
def check_arity_of_constructor load(nil) rescue ArgumentError raise ArgumentError, "Cannot serialize #{object_class}. Classes passed to `serialize` must have a 0 argument constructor." end
#coder
[ GitHub ]# File 'activerecord/lib/active_record/coders/yaml_column.rb', line 77
def coder # This is to retain forward compatibility when loading records serialized with Marshal # from a previous version of Rails. @coder ||= begin permitted_classes = defined?(@permitted_classes) ? @permitted_classes : [] unsafe_load = defined?(@unsafe_load) && @unsafe_load.nil? SafeCoder.new(permitted_classes: permitted_classes, unsafe_load: unsafe_load) end end
#init_with(coder)
[ GitHub ]# File 'activerecord/lib/active_record/coders/yaml_column.rb', line 68
def init_with(coder) # :nodoc: unless coder["coder"] permitted_classes = coder["permitted_classes"] || [] unsafe_load = coder["unsafe_load"] || false coder["coder"] = SafeCoder.new(permitted_classes: permitted_classes, unsafe_load: unsafe_load) end super(coder) end