lib/on_form/rails_compat.rb
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
# parentheses to have the parameters typecasted before they're used in the constructor. Use i for Integer and
# f for Float. If all the values for a given attribute are empty, the attribute will be set to +nil+.
Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
by calling new on the column type or aggregation type (through composed_of) object with these parameters.
Instantiates objects for all attribute classes that needs more than one constructor parameter . This is done by calling new on the column type or aggregation type ( through composed_of ) object with these parameters .
def execute_callstack_for_multiparameter_attributes(callstack)
      errors = []
      callstack.each do |name, values_with_empty_parameters|
        begin
          if defined?(ActiveRecord::AttributeAssignment::MultiparameterAttribute)
            backing_model, backing_name = backing_for_attribute(name)
            send("#{name}=", ActiveRecord::AttributeAssignment::MultiparameterAttribute.new(backing_model, backing_name.to_s, values_with_empty_parameters).read_value)
          else
            if values_with_empty_parameters.each_value.all?(&:nil?)
              values = nil
            else
              values = values_with_empty_parameters
            end
            send("#{name}=", values)
          end
        rescue => ex
          errors << ActiveRecord::AttributeAssignmentError.new("error on assignment #{values_with_empty_parameters.values.inspect} to #{name} (#{ex.message})", ex, name)
        end
      end
      unless errors.empty?
        error_descriptions = errors.map(&:message).join(",")
        raise ActiveRecord::MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes [#{error_descriptions}]"
      end
    end
def execute_callstack_for_multiparameter_attributes ( callstack ) errors = [ ] callstack . each do | name , values_with_empty_parameters | begin if defined? ( ActiveRecord :: AttributeAssignment :: MultiparameterAttribute ) backing_model , backing_name = backing_for_attribute ( name ) send ( "#{name}=" , ActiveRecord :: AttributeAssignment :: MultiparameterAttribute . new ( backing_model , backing_name . to_s , values_with_empty_parameters ) . read_value ) else if values_with_empty_parameters . each_value . all? ( & :nil? ) values = nil else values = values_with_empty_parameters end send ( "#{name}=" , values ) end rescue => ex errors << ActiveRecord :: AttributeAssignmentError . new ( "error on assignment #{values_with_empty_parameters.values.inspect} to #{name} (#{ex.message})" , ex , name ) end end unless errors . empty? error_descriptions = errors . map ( & :message ) . join ( "," ) raise ActiveRecord :: MultiparameterAssignmentErrors . new ( errors ) , "#{errors.size} error(s) on assignment of multiparameter attributes [#{error_descriptions}]" end end
Instantiates objects for all attribute classes that needs more than one constructor parameter.
Instantiates objects for all attribute classes that needs more than one constructor parameter .
# ActiveRecord 4.2 and below: you must use MultiparameterAttribute to construct the attribute value. # we therefore have to look up which model the attribute actually lives on. # ActiveRecord 5.0+: you can assign the indexed hash to the column and it will construct the value for you.
callstack
<not_specific>