Sha256: 474d9e59290a1a64e59589d918101ca42fc5db315bee826e7f043a3953f29621

Contents?: true

Size: 600 Bytes

Versions: 7

Compression:

Stored size: 600 Bytes

Contents

module CucumberFactory

  class UpdateStrategy

    def initialize(record)
      @record = record
    end

    def assign_attributes(attributes)
      active_record_strategy(attributes) ||
        ruby_object_strategy(attributes)
    end

    private

    def active_record_strategy(attributes)
      return unless @record.respond_to?(:save!)

      CucumberFactory::Switcher.assign_attributes(@record, attributes)
      @record.save!
    end

    def ruby_object_strategy(attributes)
      attributes.each do |name, value|
        @record.send("#{name}=".to_sym, value)
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cucumber_factory-2.6.0 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.5.0 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.4.1 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.4.0 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.3.1 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.3.0 lib/cucumber_factory/update_strategy.rb
cucumber_factory-2.2.0 lib/cucumber_factory/update_strategy.rb