lib/og/relation.rb in og-0.17.0 vs lib/og/relation.rb in og-0.18.0
- old
+ new
@@ -9,10 +9,13 @@
class Relation
attr_accessor :options
+ # A generalized initialize method for all relations.
+ # Contains common setup code.
+
def initialize(args, options = {})
@options = options
@options.update(args.pop) if args.last.is_a?(Hash)
if args.empty? or (not (args.last.is_a?(Class) or args.last.is_a?(Symbol)))
@@ -25,19 +28,21 @@
:target_plural_name
else
:target_singular_name
end
+ # Inflect the relation name.
+
unless args.empty?
@options[target_name] = args.first
else
@options[target_name] = if collection
target_class.to_s.demodulize.underscore.downcase.plural.intern
else
target_class.to_s.demodulize.underscore.downcase.intern
end
end
-
+
@options[:name] = options[target_name]
end
def [](key)
@options[key]