From 621b483c80d0a22b31b8f8d64f7a26e95829da44 Mon Sep 17 00:00:00 2001 From: Ken Collins Date: Tue, 23 Sep 2008 09:37:51 -0400 Subject: [PATCH] Having an instance methods file was not really needed. Moved to simple create_grouped_scope_accessor/define_method. --- lib/grouped_scope.rb | 1 - lib/grouped_scope/association_reflection.rb | 2 +- lib/grouped_scope/class_methods.rb | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/grouped_scope.rb b/lib/grouped_scope.rb index 8523513..6fc456d 100644 --- a/lib/grouped_scope.rb +++ b/lib/grouped_scope.rb @@ -3,7 +3,6 @@ require 'grouped_scope/self_grouping' require 'grouped_scope/association_reflection' require 'grouped_scope/class_methods' -require 'grouped_scope/instance_methods' require 'grouped_scope/has_many_association' module GroupedScope diff --git a/lib/grouped_scope/association_reflection.rb b/lib/grouped_scope/association_reflection.rb index 58fa449..4d813cf 100644 --- a/lib/grouped_scope/association_reflection.rb +++ b/lib/grouped_scope/association_reflection.rb @@ -40,4 +40,4 @@ def create_grouped_association end end -end \ No newline at end of file +end diff --git a/lib/grouped_scope/class_methods.rb b/lib/grouped_scope/class_methods.rb index c753205..8936c5c 100644 --- a/lib/grouped_scope/class_methods.rb +++ b/lib/grouped_scope/class_methods.rb @@ -8,11 +8,17 @@ def grouped_scopes def grouped_scope(*associations) create_belongs_to_for_grouped_scope associations.each { |association| AssociationReflection.new(self,association) } - include InstanceMethods + create_grouped_scope_accessor end private + def create_grouped_scope_accessor + define_method(:group) do + @group ||= SelfGroupping.new(self) + end + end + def create_belongs_to_for_grouped_scope grouping_class_name = 'GroupedScope::Grouping' existing_grouping = reflections[:grouping]