Browse files

way too hairy

  • Loading branch information...
1 parent bcd695a commit e813e1d9a3af8a3ffeeb2849c6b8957232a1301c @kristianmandrup committed Jun 11, 2011
Showing with 19 additions and 24 deletions.
  1. +1 −1 Gemfile
  2. +2 −2 Gemfile.lock
  3. +5 −13 lib/troles/adapters/active_record/config.rb
  4. +9 −8 lib/troles/common/config/schema.rb
  5. +2 −0 lib/troles/strategy.rb
View
2 Gemfile
@@ -1,6 +1,6 @@
source "http://rubygems.org"
-gem 'sugar-high', '~> 0.4.4'
+gem 'sugar-high', '~> 0.4.6'
gem 'require_all', '~> 1.2.0'
gem 'yard', '> 0.6.1'
View
4 Gemfile.lock
@@ -129,7 +129,7 @@ GEM
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
sqlite3 (1.3.3)
- sugar-high (0.4.5.2)
+ sugar-high (0.4.6.1)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.9)
@@ -157,5 +157,5 @@ DEPENDENCIES
rspec-rails (> 2.4.0)
shoulda
sqlite3
- sugar-high (~> 0.4.4)
+ sugar-high (~> 0.4.6)
yard (> 0.6.1)
View
18 lib/troles/adapters/active_record/config.rb
@@ -4,8 +4,9 @@ class Config < Troles::Common::Config
attr_reader :models
def initialize subject_class, options = {}
- super
- @models = Models.new subject_class, object_class, join_class
+ # super
+ # puts "models classes: #{subject_class}, #{object_model}, #{join_model}"
+ @models = Models.new subject_class, nil, nil # object_model, join_model
end
def configure_relation
@@ -35,16 +36,7 @@ def main_field
role_field
end
- def object_model
- role_model
- end
-
def join_model
- role_join_model
- end
-
-
- def role_join_model
@join_model_found ||= begin
models = [@join_model, join_model_best_guess].select do |class_name|
try_class(class_name.to_s.camelize)
@@ -59,14 +51,14 @@ def join_model_best_guess
"#{subject_class.to_s.pluralize}#{object_model.to_s.pluralize}"
end
- def role_join_model= model_class
+ def join_model= model_class
@join_model = model_class and return if model_class.any_kind_of?(Class, String, Symbol)
raise "The role model must be a Class, was: #{model_class}"
end
def join_key
- make_key role_join_model
+ make_key join_model
end
def configure_join_model
View
17 lib/troles/common/config/schema.rb
@@ -17,8 +17,9 @@ def configure_models
configure_relation if auto_config?(:relations)
end
- def configure_generic
- subject_class.send(:attr_accessor, role_field) if generic? || orm == :generic # create troles accessor
+ def configure_generic
+
+ # subject_class.send(:attr_accessor, main_field) if generic? || orm == :generic # create troles accessor
end
# Adapter should customize this as needed
@@ -32,21 +33,21 @@ def configure_relation
# Sets the role model to use
# allows different role subject classes (fx User Accounts) to have different role schemas
# @param [Class] the model class
- def role_model= model_class
- @role_model = model_class.to_s and return if model_class.any_kind_of?(Class, String, Symbol)
- raise "The role model must be a Class, was: #{model_class}"
+ def object_model= model_class
+ @object_model = model_class.to_s and return if model_class.any_kind_of?(Class, String, Symbol)
+ raise "The object model must be a Class, was: #{model_class}"
end
# Gets the role model to be used
# see (#role_model=)
# @return [Class] the model class (defaults to Role)
- def role_model
- @role_model_found ||= find_first_class(role_model, default_role_class_name)
+ def object_model
+ @object_model_found ||= find_first_class(object_model, default_object_model_class_name)
end
protected
- def default_role_class_name
+ def default_object_model_class_name
'Role'
end
View
2 lib/troles/strategy.rb
@@ -1,3 +1,5 @@
+puts "BaseMany"
+
# @author Kristian Mandrup
#
# Base module for Many roles strategies

0 comments on commit e813e1d

Please sign in to comment.