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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6230cad73b222d649619c703d4b51c964066906a
4
- data.tar.gz: bd970221b8047f0a0f71ef56f36bd938c8d03b10
3
+ metadata.gz: 1dc6b17c9688394c13aef7385e475ff2ae619e97
4
+ data.tar.gz: ae971480393fe3d8566c7c00651aee3531702d28
5
5
  SHA512:
6
- metadata.gz: 77bf9fc4c2647025f6d56136c3ba766bc3fb96c72be41b78527819b9074fc93b1b10af1e270044b6d53c932d9c4d57af0552dfbd855d9ec29a119c1975275b78
7
- data.tar.gz: 2a8a83fb8d82807e3e9c46aa6433db600cc17cae0affc01e8c3f497f6e62954864989528a6109f2836c22f161878853d97f9b9c3d1c00e3f3386c1ebf34fdbd5
6
+ metadata.gz: 5112a358955c915551d88ebaa38817064a11f4e952e2567594ff10fb9788a05c3bb4b57fdc61e71263748c8932527e57a4fb1f1f7bebbbe513653b9a03be4703
7
+ data.tar.gz: 10bc3a597166bbc4cc9fa84c5a9148df354f3a3935ffc0770f7c38aaa520e1a771640409d757a12a97581ac692d767800d245d86d4b675100f325abe15f6c1cf
Binary file
data/lib/a_r_mocker.rb CHANGED
@@ -3,7 +3,6 @@ require 'a_r_mocker/version'
3
3
  require 'a_r_mocker/models'
4
4
  require 'a_r_mocker/model'
5
5
  require 'a_r_mocker/relation'
6
- require 'a_r_mocker/relation/has_many'
7
6
 
8
7
  module ARMocker
9
8
  end
@@ -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(:persisted)
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,
@@ -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, persisted, attributes = {})
12
- @members = Array.new(count, ARMocker::Model.new(attributes.merge(persisted: 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
@@ -2,3 +2,5 @@ module ARMocker
2
2
  module Relation
3
3
  end
4
4
  end
5
+
6
+ require_relative 'relation/has_many'
@@ -1,3 +1,3 @@
1
1
  module ARMocker
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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