Sha256: e889a5ed40f3a2178c259919f07b08fa3772ee82f8ede56c9f125521302342c6

Contents?: true

Size: 533 Bytes

Versions: 4

Compression:

Stored size: 533 Bytes

Contents

module Machinist::ActiveRecord

  class Lathe < Machinist::Lathe

    def make_one_value(attribute, args) #:nodoc:
      if block_given?
        raise_argument_error(attribute) unless args.empty?
        yield
      else
        make_association(attribute, args)
      end
    end

    def make_association(attribute, args) #:nodoc:
      association = @klass.reflect_on_association(attribute)
      if association
        association.klass.make(*args)
      else
        raise_argument_error(attribute)
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
machinist-2.0 lib/machinist/active_record/lathe.rb
indirect-machinist-2.0.0.beta3 lib/machinist/active_record/lathe.rb
machinist-2.0.0.beta2 lib/machinist/active_record/lathe.rb
machinist-2.0.0.beta1 lib/machinist/active_record/lathe.rb