Sha256: d3ace83406821f801caa0e87a8c3f8e6ab18f16fd963d306877613fdbde5c61c

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Machinist::DataMapper

  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.relationships[attribute]
      if association
        if association.is_a?(DataMapper::Associations::ManyToOne::Relationship)
          association.parent_model.make(*args)
        else
          association.child_model.make(*args)
        end
      else
        raise_argument_error(attribute)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-machinist-0.0.1 lib/machinist/data_mapper/lathe.rb