class CucumberFactory::UpdateStrategy

Public Class Methods

new(record) click to toggle source
# File lib/cucumber_factory/update_strategy.rb, line 5
def initialize(record)
  @record = record
end

Public Instance Methods

assign_attributes(attributes) click to toggle source
# File lib/cucumber_factory/update_strategy.rb, line 9
def assign_attributes(attributes)
  active_record_strategy(attributes) ||
    ruby_object_strategy(attributes)
end

Private Instance Methods

active_record_strategy(attributes) click to toggle source
# File lib/cucumber_factory/update_strategy.rb, line 16
def active_record_strategy(attributes)
  return unless @record.respond_to?(:save!)

  CucumberFactory::Switcher.assign_attributes(@record, attributes)
  @record.save!
end
ruby_object_strategy(attributes) click to toggle source
# File lib/cucumber_factory/update_strategy.rb, line 23
def ruby_object_strategy(attributes)
  attributes.each do |name, value|
    @record.send("#{name}=".to_sym, value)
  end
end