Module: Norman::ActiveModel::ClassMethods

Defined in:
lib/norman/active_model.rb

Instance Method Summary collapse

Instance Method Details

#create!(*args) ⇒ Object

Create and save a model instance, raising an exception if any errors occur.



48
49
50
# File 'lib/norman/active_model.rb', line 48

def create!(*args)
  new(*args).save!
end

#model_nameObject



57
58
59
# File 'lib/norman/active_model.rb', line 57

def model_name
  @model_name ||= ::ActiveModel::Name.new(self)
end

#validates_uniqueness_of(*attr_names) ⇒ Object

Validate the uniqueness of a field’s value in a model instance.



53
54
55
# File 'lib/norman/active_model.rb', line 53

def validates_uniqueness_of(*attr_names)
  validates_with Validations::Uniqueness, _merge_attributes(attr_names)
end