lib/acl9/controller_extensions/dsl_base.rb in acl9-3.0.0 vs lib/acl9/controller_extensions/dsl_base.rb in acl9-3.1.0
- old
+ new
@@ -10,10 +10,11 @@
def initialize(*args)
@default_action = nil
@allows = []
@denys = []
@original_args = args
+ @action_clause = nil
end
def acl_block!(&acl_block)
instance_eval(&acl_block)
end
@@ -106,19 +107,19 @@
options = args.extract_options!
options.keys.each { |key| _permitted_allow_deny_option!(key) }
_set_action_clause( _retrieve_only(options), options.delete(:except))
- object = _role_object(options)
+ object_s = _role_object_s(options)
role_checks = args.map do |who|
case who
when anonymous then "#{_subject_ref}.nil?"
when logged_in then "!#{_subject_ref}.nil?"
when all then "true"
else
- "!#{_subject_ref}.nil? && #{_subject_ref}.has_role?('#{who}', #{object})"
+ "!#{_subject_ref}.nil? && #{_subject_ref}.has_role?('#{who}'#{object_s})"
end
end
[:if, :unless].each do |cond|
val = options[cond]
@@ -177,16 +178,16 @@
"#{set_of_actions}.include?(#{_action_ref})"
end
end
- def _role_object(options)
+ def _role_object_s(options)
object = _by_preposition options
case object
- when Class then object.to_s
- when Symbol then _object_ref object
- when nil then "nil"
+ when Class then ", #{object}"
+ when Symbol then ", #{_object_ref object}"
+ when nil then ""
else
raise ArgumentError, "object specified by preposition can only be a Class or a Symbol"
end
end