lib/cantango/permits/user_permit/builder.rb in cantango-0.8.7 vs lib/cantango/permits/user_permit/builder.rb in cantango-0.8.8
- old
+ new
@@ -3,13 +3,23 @@
class UserPermit < CanTango::Permit
class Builder < CanTango::PermitEngine::Builder::Base
# class NoAvailableRoles < StandardError; end
# builds a list of Permits for each role of the current ability user (or account)
- # @return [Array<RoleGroupPermit::Base>] the role permits built for this ability
+ # @return [Array<Permit::Base>] the role permits built for this ability
def build
- # raise NoAvailableRoles, "no available roles are defined" if available_roles.empty?
- [] << create_permit(user.class.to_s)
+ puts debug_msg if CanTango.debug?
+ [permit].compact
+ end
+
+ protected
+
+ def debug_msg
+ permit ? "Building UserPermit for #{user}, permit: #{permit}" : "Not building any UserPermit"
+ end
+
+ def permit
+ @permit ||= create_permit(user.class.to_s)
end
end
end
end
end