Sha256: 876b48e067ed0482fccb957f58333ea4ce7a8c55ab9573e36d4d17be2c5aa4af
Contents?: true
Size: 922 Bytes
Versions: 13
Compression:
Stored size: 922 Bytes
Contents
module NinjaModel module Associations module Builder class BelongsTo < SingularAssociation self.macro = :belongs_to def build reflection = super configure_dependency reflection end private def configure_dependency if options[:dependent] unless options[:dependenc].in?([:destroy, :delete]) raise ArgumentError, "The :dependent option expects either :destroy or delete (#{options[:dependent].inspect})" end method_name = "belongs_to_dependent_#{options[:dependent]}_for_#{name}" model.send(:class_eval, <<-eoruby, __FILE__, __LINE__ + 1) def #{method_name} association = #{name} association.#{options[:dependent]} if association end eoruby end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems