Module: SeedPacket

Defined in:
lib/seed_packet.rb,
lib/seed_packet/version.rb,
lib/seed_packet/environment.rb

Defined Under Namespace

Classes: Environment

Constant Summary collapse

VERSION =
'0.1.2'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



8
9
10
# File 'lib/seed_packet.rb', line 8

def environment
  @environment
end

#factory_classObject

Returns the value of attribute factory_class.



8
9
10
# File 'lib/seed_packet.rb', line 8

def factory_class
  @factory_class
end

Instance Method Details

#initialize(environment: nil, factory_class: 'FactoryBot') ⇒ Object

rubocop:disable Metrics/LineLength



12
13
14
15
16
# File 'lib/seed_packet.rb', line 12

def initialize(environment: nil, factory_class: 'FactoryBot')
  self.environment = environment ? Environment.new(environment) : nil

  self.factory_class = Object.const_get(factory_class) if self.environment.samples_allowed?
end

#sampleObject



23
24
25
# File 'lib/seed_packet.rb', line 23

def sample
  yield if environment.samples_allowed?
end

#scrubObject



27
28
29
# File 'lib/seed_packet.rb', line 27

def scrub
  yield if environment.scrubbing_allowed?
end

#seedObject

rubocop:enable Metrics/LineLength



19
20
21
# File 'lib/seed_packet.rb', line 19

def seed
  yield if environment.seeding_allowed?
end