class Rethinker::Relation::HasMany
Public Instance Methods
children_klass()
click to toggle source
# File lib/rethinker/relation/has_many.rb, line 10 def children_klass # TODO test :class_name @children_klass ||= (options[:class_name] || children_name.to_s.singularize.camelize).constantize end
foreign_key()
click to toggle source
# File lib/rethinker/relation/has_many.rb, line 5 def foreign_key # TODO test :foreign_key @foreign_key ||= options[:foreign_key] || :"#{parent_klass.name.underscore}_id" end
hook()
click to toggle source
# File lib/rethinker/relation/has_many.rb, line 15 def hook # TODO yell when some options are not recognized parent_klass.inject_in_layer :relations, <<-RUBY, __FILE__, __LINE__ + 1 def #{children_name}=(new_children) #{children_name}.destroy new_children.each { |child| #{children_name} << child } end def #{children_name} # TODO Cache array relation = self.class.relations[:#{children_name}] ::Rethinker::Relation::HasMany::Selection.new(self, relation) end RUBY end