Class: Fixturizer::Engines::Record
- Inherits:
-
Object
- Object
- Fixturizer::Engines::Record
- Defined in:
- lib/fixturizer/engines/records.rb
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(value:, rule:) ⇒ Record
constructor
A new instance of Record.
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
#apply ⇒ Object
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 |