lib/rolypoly/role_gatekeeper.rb in rolypoly-1.0.3 vs lib/rolypoly/role_gatekeeper.rb in rolypoly-1.0.4
- old
+ new
@@ -84,20 +84,15 @@
private def allowed_resource?(check_role, required_resource)
return true unless require_resource?
return false unless check_role.respond_to?(:resource?)
- if resources?(required_resource)
- required_resource.any? do |r|
- check_role.resource?(r)
- end
- else
- check_role.resource?(required_resource)
- end
+ required_resources = type_id_resource?(required_resource) ? [required_resource] : Array(required_resource)
+ required_resources.any? {|r| check_role.resource?(r) }
end
- private def resources?(resources)
- resources.is_a?(Array) && !%w(String Symbol).include?(resources.first.class.name)
+ private def type_id_resource?(required_resource)
+ required_resource.is_a?(Array) && %w(String Symbol).include?(required_resource.first.class.name)
end
private def find_required_resource(options = {})
return resource unless %w(String Symbol).include?(resource.class.to_s)