Module: Arpa::Repositories::Registrator

Instance Method Summary collapse

Methods included from Base

#mapper_instance, #repository_class

Instance Method Details

#create(entity) ⇒ Object



6
7
8
# File 'lib/arpa/repositories/registrator.rb', line 6

def create(entity)
  save(entity, &:save!)
end

#update(entity) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/arpa/repositories/registrator.rb', line 10

def update(entity)
  save(entity) do |record|
    record.updated_at = Time.new.utc
    attributes        = record.attributes.except('id', 'created_at')

    repository_class.update(entity.id, attributes)

    record.reload
    record.reload
    post_update(entity, record)
  end
end