Sha256: 3c5066f547048d6e0a6cc7619cd1fee27b0ed6e204f15a602a33406d005811e2

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 Bytes

Contents

module Machinist
  module 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
machinist_redux-3.0.4 lib/machinist/active_record/lathe.rb
machinist_redux-3.0.3 lib/machinist/active_record/lathe.rb
machinist_redux-3.0.2 lib/machinist/active_record/lathe.rb