Class: ARMocker::Models
- Inherits:
-
Object
- Object
- ARMocker::Models
- Includes:
- Enumerable
- Defined in:
- lib/a_r_mocker/models.rb
Overview
Generates multiple Models. Attributes passed are applied to every model generated.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(count, attributes = {}) ⇒ Models
constructor
have persisted.
- #to_a ⇒ Object
Constructor Details
#initialize(count, attributes = {}) ⇒ Models
have persisted
10 11 12 |
# File 'lib/a_r_mocker/models.rb', line 10 def initialize(count, attributes = {}) @members = Array.new(count, ARMocker::Model.new(attributes.merge(persisted: attributes.slice(:_persisted)))) end |
Class Method Details
.create(count, attributes = {}) ⇒ Object
14 15 16 |
# File 'lib/a_r_mocker/models.rb', line 14 def self.create(count, attributes = {}) new(count, attributes.merge(_persisted: true)) end |
Instance Method Details
#to_a ⇒ Object
18 19 20 |
# File 'lib/a_r_mocker/models.rb', line 18 def to_a @members end |