lib/roles_generic/base.rb in roles_generic-0.1.1 vs lib/roles_generic/base.rb in roles_generic-0.2.0
- old
+ new
@@ -1,28 +1,24 @@
-require 'require_all'
-require 'active_support/inflector'
-
-module RoleModels
- module Generic
- end
-end
-
-module RoleModels
+module Roles
module Base
attr_accessor :orm_name
+ def valid_roles
+ strategy_class.valid_roles
+ end
+
def roles(*roles)
strategy_class.valid_roles = Array[*roles].flatten.map { |r| r.to_sym }
end
- def role_strategy strategy, options=nil
- include_strategy orm_name, strategy, options
+ def role_strategy strategy_name, options=nil
+ include_strategy orm_name, strategy_name, options
end
- def include_strategy orm, strategy, options=nil
+ def include_strategy orm, strategy_name, options=nil
begin
- constant = "RoleModels::#{orm_name.to_s.camelize}::#{strategy.to_s.camelize}".constantize
+ constant = "RoleStrategy::#{orm_name.to_s.camelize}::#{strategy_name.to_s.camelize}".constantize
strategy_class_method = %Q{
def strategy_class
#{constant}
end
@@ -35,11 +31,11 @@
instance_eval do
eval strategy_class_method
include constant
end
rescue
- raise "No Role strategy module for ORM #{orm} found for strategy #{strategy}"
+ raise "No Role strategy module for ORM #{orm} found for strategy #{strategy_name}"
end
constant.apply_options(options) if constant.respond_to? :apply_options
end
end
-end
+end
\ No newline at end of file