lib/roles_generic/strategy.rb in roles_generic-0.3.3 vs lib/roles_generic/strategy.rb in roles_generic-0.3.4
- old
+ new
@@ -1,19 +1,23 @@
require 'sugar-high/file'
require 'sugar-high/array'
module Roles::Strategy
class << self
- NON_INLINE_STRATEGIES = [:one_role, :many_roles]
+ NON_INLINE_STRATEGIES = [:one_role, :many_roles, :embed_one_role, :embed_many_roles]
def role_dir
File.dirname(__FILE__)
end
def gem_name
:roles_generic
end
+
+ def embedded? strategy
+ strategy.to_s.include? 'embed'
+ end
def role_strategies cardinality
pattern = role_dir + "/strategy/#{cardinality}/*.rb"
Dir.glob(pattern).file_names(:rb).to_symbols
end
@@ -39,8 +43,9 @@
cardinality = Roles::Strategy.cardinality(strategy)
require "roles_generic/strategy/#{cardinality}/#{strategy}"
require "roles_generic/admin" if strategy =~ /admin/
gem_name = Roles::Strategy.gem_name
- require "#{gem_name}/role" if !Roles::Strategy.inline_strategy? strategy
+ prefix = Roles::Strategy.embedded?(strategy) ? 'embedded_' : ''
+ require "#{gem_name}/#{prefix}role" if !Roles::Strategy.inline_strategy?(strategy)
require "#{gem_name}/strategy/#{cardinality}/#{strategy}"
end
\ No newline at end of file