Class: Fixturizer::Engines::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/fixturizer/engines/records.rb

Instance Method Summary collapse

Constructor Details

#initialize(value:, rule:) ⇒ Record



6
7
8
9
10
11
12
# File 'lib/fixturizer/engines/records.rb', line 6

def initialize(value:, rule:)
  # @configuration = Fixturizer::Configuration::new filename: './config/rules.yml'
  @configuration = Fixturizer::Services.get.configuration
  @rules = @configuration.rules
  @record = value
  @rule = rule.is_a?(Symbol) ? @rules[rule] : rule
end

Instance Method Details

#applyObject



14
15
16
17
18
19
20
# File 'lib/fixturizer/engines/records.rb', line 14

def apply
  result = @record
  return result if @rule.nil?

  result = eval("lambda { #{@rule[:proc]} } ").call unless (@rule[:preserve] == true) && !@record.nil?
  result
end