repositor 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a835c07a8cc827540622af5ae3b509078e410dc7
4
- data.tar.gz: 5f727e08def247a8fbce3741ed160def88b94631
3
+ metadata.gz: af297e7c3e066d3e865ceb83c2b1086fb5e04494
4
+ data.tar.gz: bacf7f17f2ef25a76e6791aaf86c015c199c555f
5
5
  SHA512:
6
- metadata.gz: 709cdc84bbf37a0b5c9da5e4aad0b073560a6c330991ecafd2576d8cb4cb87e139a450fb01ab9eb9f6d7033d9bdf1ac869010a455dc49d12dae58c90d43a450a
7
- data.tar.gz: 1b5ca23b4479bfcb8864609a7f5e2f6d18ccf0b7efa61a2b41f57ea4471326aa3c2f2e9073867b745280813f7d852256ee82f5b3ecc47223f09547f304fe32c9
6
+ metadata.gz: 8a260827f8d71f4b85313cd754256b12907441f747ff3c915e46829ece3159ed2640375a9b1b3b737a3040fcab06d304ffa040460a6a4ac898c42a2ada384f3f
7
+ data.tar.gz: 9275022dafed019e74b93215dd8bf8dd083fe8d9d9a69c63b52cdc73bd7818ba0df4e4d89979e6b03cb999b062d36a93e6d96faa10bac13a25f2a58096a9c5b1
@@ -2,7 +2,7 @@ module Repositor
2
2
  module ActiveRecord
3
3
  attr_reader :model
4
4
 
5
- delegate :find, :all, :new, :create, to: :model
5
+ delegate :find, :all, :new, :create, :update, to: :model
6
6
 
7
7
  def initialize(model: nil)
8
8
  @model = model || self.class.to_s.chomp("Repo").singularize.constantize
@@ -12,8 +12,10 @@ module Repositor
12
12
  model.friendly.find(id)
13
13
  end
14
14
 
15
- def update(record, record_params)
16
- record.update(record_params)
15
+ def find_or_initialize(id, friendly: false)
16
+ friendly ? friendly_find(id) : model.find(id)
17
+ rescue ActiveRecord::RecordNotFound
18
+ model.new
17
19
  end
18
20
 
19
21
  def destroy(record)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repositor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk