avoid #respond_to? in Cache.id_for
This commit is contained in:
parent
e515aa548c
commit
45e9d28791
|
@ -21,11 +21,14 @@ module DeclarativePolicy
|
|||
private
|
||||
|
||||
def id_for(obj)
|
||||
if obj.respond_to?(:id) && obj.id
|
||||
obj.id.to_s
|
||||
else
|
||||
"##{obj.object_id}"
|
||||
end
|
||||
id =
|
||||
begin
|
||||
obj.id
|
||||
rescue NoMethodError
|
||||
nil
|
||||
end
|
||||
|
||||
id || "##{obj.object_id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue