a_r_mocker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/a_r_mocker-0.0.1.gem +0 -0
- data/lib/a_r_mocker.rb +0 -1
- data/lib/a_r_mocker/model.rb +5 -1
- data/lib/a_r_mocker/models.rb +6 -2
- data/lib/a_r_mocker/relation.rb +2 -0
- data/lib/a_r_mocker/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc6b17c9688394c13aef7385e475ff2ae619e97
|
4
|
+
data.tar.gz: ae971480393fe3d8566c7c00651aee3531702d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5112a358955c915551d88ebaa38817064a11f4e952e2567594ff10fb9788a05c3bb4b57fdc61e71263748c8932527e57a4fb1f1f7bebbbe513653b9a03be4703
|
7
|
+
data.tar.gz: 10bc3a597166bbc4cc9fa84c5a9148df354f3a3935ffc0770f7c38aaa520e1a771640409d757a12a97581ac692d767800d245d86d4b675100f325abe15f6c1cf
|
Binary file
|
data/lib/a_r_mocker.rb
CHANGED
data/lib/a_r_mocker/model.rb
CHANGED
@@ -3,11 +3,15 @@ module ARMocker
|
|
3
3
|
# them as dummy data
|
4
4
|
class Model < OpenStruct
|
5
5
|
def initialize(hash = {})
|
6
|
-
@persisted = hash.delete(:
|
6
|
+
@persisted = hash.delete(:_persisted)
|
7
7
|
hash = default_attributes.merge(hash)
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.create(hash = {})
|
12
|
+
new(hash.merge(_persisted: true))
|
13
|
+
end
|
14
|
+
|
11
15
|
private def default_attributes
|
12
16
|
{
|
13
17
|
new_record?: !@persisted,
|
data/lib/a_r_mocker/models.rb
CHANGED
@@ -8,8 +8,12 @@ module ARMocker
|
|
8
8
|
# @param persisted [Boolean] whether the models will act as though they
|
9
9
|
# have persisted
|
10
10
|
# @param attributes [Hash] attributes to be applied to every model
|
11
|
-
def initialize(count,
|
12
|
-
@members = Array.new(count, ARMocker::Model.new(attributes.merge(persisted:
|
11
|
+
def initialize(count, attributes = {})
|
12
|
+
@members = Array.new(count, ARMocker::Model.new(attributes.merge(persisted: attributes.delete(:_persisted))))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create(count, attributes = {})
|
16
|
+
new(count, attributes.merge(_persisted: true))
|
13
17
|
end
|
14
18
|
|
15
19
|
def to_a
|
data/lib/a_r_mocker/relation.rb
CHANGED
data/lib/a_r_mocker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: a_r_mocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Spiel
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- Gemfile
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- a_r_mocker-0.0.1.gem
|
69
70
|
- a_r_mocker.gemspec
|
70
71
|
- bin/console
|
71
72
|
- bin/setup
|