class Cuprum::Rails::Commands::BuildOne

Command for generating an ActiveRecord model from an attributes hash.

Private Instance Methods

process(attributes:) click to toggle source
# File lib/cuprum/rails/commands/build_one.rb, line 44
def process(attributes:)
  record_class.new(attributes)
rescue ActiveModel::UnknownAttributeError => exception
  error = Cuprum::Collections::Errors::ExtraAttributes.new(
    entity_class:     record_class,
    extra_attributes: [exception.attribute],
    valid_attributes: record_class.attribute_names
  )
  failure(error)
end