class CucumberFactory::UpdateStrategy
Public Class Methods
Source
# File lib/cucumber_factory/update_strategy.rb, line 5 def initialize(record) @record = record end
Public Instance Methods
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
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
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