class ARMocker::Models

Generates multiple Models. Attributes passed are applied to every model generated.

Public Class Methods

create(count, attributes = {}) click to toggle source
# File lib/a_r_mocker/models.rb, line 14
def self.create(count, attributes = {})
  new(count, attributes.merge(_persisted: true))
end
new(count, attributes = {}) click to toggle source

@param count [Integer] the number of models to be generated have persisted @param attributes [Hash] attributes to be applied to every model

# 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

Public Instance Methods

to_a() click to toggle source
# File lib/a_r_mocker/models.rb, line 18
def to_a
  @members
end