active_mocker 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_hash/ar_api.rb +19 -15
- data/lib/active_mocker/base.rb +1 -1
- data/lib/active_mocker/version.rb +1 -1
- 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: d9940d5208df11f3cc98ab2172753293c4e6e480
|
4
|
+
data.tar.gz: 37c61f9c1cf275c9807f0de8b2f3c0bbdceedc30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c49ea8b615fb04c03e59a75415dba2f906c262917785f8e1c8f5c6a49228425e2959f1c8d23c5819c5a3847c4380753b5b3bf6327528005237bcd1678b183820
|
7
|
+
data.tar.gz: 540acf96d88c6df5c474e8b69c40d92d3b6d4d4b691a87a71a55f558bf13b60da3ebb6d8e71c2ca48001c883569b317d5479923c32bde557bcef687f86c0cdb7
|
data/lib/active_hash/ar_api.rb
CHANGED
@@ -2,31 +2,35 @@ require_relative 'destroy_all'
|
|
2
2
|
require_relative 'update'
|
3
3
|
require_relative 'find_by'
|
4
4
|
require_relative 'init'
|
5
|
+
module ActiveMocker
|
6
|
+
module ActiveHash
|
5
7
|
|
6
|
-
module
|
8
|
+
module ARApi
|
7
9
|
|
8
|
-
|
10
|
+
include ::ActiveHash::ARApi::Update
|
11
|
+
include ::ActiveHash::ARApi::Init
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
def self.included(base)
|
14
|
+
base.extend(ClassMethods)
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
module ClassMethods
|
18
|
+
include ::ActiveHash::ARApi::DestroyAll
|
19
|
+
include ::ActiveHash::ARApi::FindBy
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
def find_or_create_by(attributes)
|
22
|
+
find_by(attributes) || create(attributes)
|
23
|
+
end
|
20
24
|
|
21
|
-
|
22
|
-
|
25
|
+
def find_or_initialize_by(attributes)
|
26
|
+
find_by(attributes) || new(attributes)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
|
-
def find_or_initialize_by(attributes)
|
26
|
-
find_by(attributes) || new(attributes)
|
27
|
-
end
|
28
30
|
end
|
29
31
|
|
32
|
+
|
33
|
+
|
30
34
|
end
|
31
35
|
|
32
36
|
end
|
data/lib/active_mocker/base.rb
CHANGED
@@ -216,7 +216,7 @@ module ActiveMocker
|
|
216
216
|
|
217
217
|
def const_class
|
218
218
|
remove_const(mock_class_name) if class_exists? mock_class_name
|
219
|
-
klass = Object.const_set(mock_class_name ,Class.new(ActiveHash::Base)) if active_hash_as_base
|
219
|
+
klass = Object.const_set(mock_class_name ,Class.new(::ActiveHash::Base)) if active_hash_as_base
|
220
220
|
klass.send(:include, ActiveHash::ARApi) if active_hash_as_base
|
221
221
|
klass = Object.const_set(mock_class_name ,Class.new()) unless active_hash_as_base
|
222
222
|
klass.extend ModelClassMethods
|