Module: Madoka::Model

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Model, ActiveRecord::AttributeAssignment
Defined in:
lib/madoka/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ActiveModel::Model

included, #persisted?

Instance Method Details

#initialize(params = nil, options = {}) ⇒ Object



17
18
19
# File 'lib/madoka/model.rb', line 17

def initialize(params = nil, options = {})
  assign_attributes(params, options.slice(:as)) if params
end

#saveObject



21
22
23
24
# File 'lib/madoka/model.rb', line 21

def save
  result = valid?
  run_callbacks(:save) { result }
end

#save!Object



26
27
28
29
# File 'lib/madoka/model.rb', line 26

def save!
  result = valid?
  run_callbacks(:save) { result or raise(ModelInvalid.new(self)) }
end