lib/sequel_model/associations.rb in sequel_model-0.5 vs lib/sequel_model/associations.rb in sequel_model-0.5.0.1
- old
+ new
@@ -78,16 +78,13 @@
# model object can be associated with many current model objects.
# Similar to ActiveRecord/DataMapper's has_and_belongs_to_many.
#
# The following options can be supplied:
# * *ALL types*:
- # - :class_name - The name of the associated class as a string. If not
+ # - :class - The associated class or its name. If not
# given, uses the association's name, which is camelized (and
# singularized if type is :{one,many}_to_many)
- # - :class - The associated class itself. Simpler than using
- # :class_name, but can't be used always due to dependencies not being
- # loaded.
# * :many_to_one:
# - :key - foreign_key in current model's table that references
# associated model's primary key, as a symbol. Defaults to :"#{name}_id".
# * :one_to_many:
# - :key - foreign key in associated model's table that references
@@ -115,10 +112,10 @@
STDERR << "The :from option is deprecated, please use the :class option instead.\r\n"
opts[:class] = opts[:from]
end
# prepare options
- opts[:class_name] ||= opts[:class].name if opts[:class]
+ opts[:class_name] ||= opts[:class].to_s if opts[:class]
opts = association_reflections[name] = opts.merge(:type => type, :name => name, :block => block)
send(:"def_#{type}", name, opts)
end