module Mince::Model::DataModel

Protected Instance Methods

ensure_no_extra_fields() click to toggle source

Ensures that the data model has all of the fields that are trying to be saved. Raises an exception if the data model does not.

Not sure if this is where this method should live, it requires both Mince::Model::DataModel and Mince::Model::Fields.

# File lib/mince/model/data_model.rb, line 23
def ensure_no_extra_fields
  if !data_model.infer_fields? && extra_fields.any?
    raise "Tried to save a #{self.class.name} with fields not specified in #{data_model.name}: #{extra_fields.join(', ')}"
  end
end
extra_fields() click to toggle source
# File lib/mince/model/data_model.rb, line 29
def extra_fields
  @extra_fields ||= (fields - data_model.data_fields)
end