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 +4 -4
- data/lib/repositor/active_record.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af297e7c3e066d3e865ceb83c2b1086fb5e04494
|
4
|
+
data.tar.gz: bacf7f17f2ef25a76e6791aaf86c015c199c555f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
16
|
-
|
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)
|